cart

Hide coupon discount raw if no coupon has been applied on WooCommerce cart page

久未见 提交于 2021-01-07 00:57:49
问题 I add coupons and discounts total savings to my cart page. My code works fine but I have an additional question. This is the code I am currently using: add_action( 'woocommerce_cart_totals_before_shipping', 'show_total_discount_cart_checkout', 9999 ); function show_total_discount_cart_checkout() { global $woocommerce; $discount_total = 0; foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { $product = $values['data']; if ( $product->is_on_sale() ) { $regular_price = $product->get

Auto add to cart a Gift product variation programmatically in WooCommerce?

倾然丶 夕夏残阳落幕 提交于 2021-01-06 03:29:48
问题 I'm trying to create a buy one get one offer for woocommerce when someone adds a product to the cart. The code below works but only with simple products, I've tried adding the variation ID to the variable but it does not work. Any ideas? thanks to the community add_action( 'template_redirect', 'bbloomer_add_gift_if_id_in_cart' ); function bbloomer_add_gift_if_id_in_cart() { if ( is_admin() ) return; if ( WC()->cart->is_empty() ) return; $product_bought_id = 421; $product_gifted_id = 1256; //

Auto add to cart a Gift product variation programmatically in WooCommerce?

混江龙づ霸主 提交于 2021-01-06 03:28:34
问题 I'm trying to create a buy one get one offer for woocommerce when someone adds a product to the cart. The code below works but only with simple products, I've tried adding the variation ID to the variable but it does not work. Any ideas? thanks to the community add_action( 'template_redirect', 'bbloomer_add_gift_if_id_in_cart' ); function bbloomer_add_gift_if_id_in_cart() { if ( is_admin() ) return; if ( WC()->cart->is_empty() ) return; $product_bought_id = 421; $product_gifted_id = 1256; //

Auto add to cart a Gift product variation programmatically in WooCommerce?

倾然丶 夕夏残阳落幕 提交于 2021-01-06 03:28:27
问题 I'm trying to create a buy one get one offer for woocommerce when someone adds a product to the cart. The code below works but only with simple products, I've tried adding the variation ID to the variable but it does not work. Any ideas? thanks to the community add_action( 'template_redirect', 'bbloomer_add_gift_if_id_in_cart' ); function bbloomer_add_gift_if_id_in_cart() { if ( is_admin() ) return; if ( WC()->cart->is_empty() ) return; $product_bought_id = 421; $product_gifted_id = 1256; //

Auto add to cart a Gift product variation programmatically in WooCommerce?

佐手、 提交于 2021-01-06 03:27:10
问题 I'm trying to create a buy one get one offer for woocommerce when someone adds a product to the cart. The code below works but only with simple products, I've tried adding the variation ID to the variable but it does not work. Any ideas? thanks to the community add_action( 'template_redirect', 'bbloomer_add_gift_if_id_in_cart' ); function bbloomer_add_gift_if_id_in_cart() { if ( is_admin() ) return; if ( WC()->cart->is_empty() ) return; $product_bought_id = 421; $product_gifted_id = 1256; //

Add free gifted product for a minimal cart amount in WooCommerce

血红的双手。 提交于 2021-01-05 11:26:32
问题 I want to give customers with orders above $50 a free gift. Not if a specific product is in the cart (there are some examples here on stackoverflow and below). After some research I found the following code to add a free product if another specific product is added to the cart. add_action( 'template_redirect', 'bbloomer_add_gift_if_id_in_cart' ); function bbloomer_add_gift_if_id_in_cart() { if ( is_admin() ) return; if ( WC()->cart->is_empty() ) return; $product_bought_id = 32; $product

Disable “cart needs payment” for a specific coupon code in Woocommerce

蓝咒 提交于 2021-01-05 10:14:14
问题 I need to hide the payment by credit card when I have a specific coupon such as "tcrfam" and when I use any different to this show the payment by card, the idea is that I do not give a coupon of 100% or free and there is no case I ask credit card data. See the example: I tried this code but dont work: add_action('woocommerce_before_checkout_form', 'apply_product_on_coupon'); function apply_product_on_coupon() { global $woocommerce; $coupon_id = 'tcrfam'; if(in_array($coupon_id, $woocommerce-

Disable “cart needs payment” for a specific coupon code in Woocommerce

假如想象 提交于 2021-01-05 10:13:41
问题 I need to hide the payment by credit card when I have a specific coupon such as "tcrfam" and when I use any different to this show the payment by card, the idea is that I do not give a coupon of 100% or free and there is no case I ask credit card data. See the example: I tried this code but dont work: add_action('woocommerce_before_checkout_form', 'apply_product_on_coupon'); function apply_product_on_coupon() { global $woocommerce; $coupon_id = 'tcrfam'; if(in_array($coupon_id, $woocommerce-

Split cart items when quantity is updated on cart page in WooCommerce

两盒软妹~` 提交于 2020-12-13 12:08:49
问题 I want to split cart items of same product in individual lines. When I increase quantity on single product page and add to cart, it shows as separate cart items. Im using WooCommerce - Treat cart items separate if quantity is more than 1 answer code. I want when quantity is updated on cart page and clicked on 'Update cart', then items must split on individual lines. How can I do that? 回答1: The code below will split items on individual lines when quantity is updated on the cart page. Comment

Split cart items when quantity is updated on cart page in WooCommerce

 ̄綄美尐妖づ 提交于 2020-12-13 12:07:13
问题 I want to split cart items of same product in individual lines. When I increase quantity on single product page and add to cart, it shows as separate cart items. Im using WooCommerce - Treat cart items separate if quantity is more than 1 answer code. I want when quantity is updated on cart page and clicked on 'Update cart', then items must split on individual lines. How can I do that? 回答1: The code below will split items on individual lines when quantity is updated on the cart page. Comment