cart

Sort specific product category cart items at the end in WooCommerce

血红的双手。 提交于 2021-02-10 05:48:07
问题 How to sort items from a defined product category to be at the end of a cart order, for example I want all products that belong to a product category 'bottle' to be at the end of the cart order. I have found this code that sorts by price, but would like to adjust to as described above. add_action( 'woocommerce_cart_loaded_from_session', 'prefix_cart_order_prod_cat' ); function prefix_cart_order_prod_cat() { $products_in_cart = array(); // Assign each product's price to its cart item key (to

Sort specific product category cart items at the end in WooCommerce

我的梦境 提交于 2021-02-10 05:48:07
问题 How to sort items from a defined product category to be at the end of a cart order, for example I want all products that belong to a product category 'bottle' to be at the end of the cart order. I have found this code that sorts by price, but would like to adjust to as described above. add_action( 'woocommerce_cart_loaded_from_session', 'prefix_cart_order_prod_cat' ); function prefix_cart_order_prod_cat() { $products_in_cart = array(); // Assign each product's price to its cart item key (to

Hide auto added gift product from WooCommerce catalog

萝らか妹 提交于 2021-02-08 11:49:24
问题 I have the following scenario that I can not solve, could you guide me, either with a plugin or from code? I have the product A and the product B, which should not appear in the store nor can it be added individually as it is a gift. If someone adds product A to the cart, then the system should add product B. It is like a BOGO, but the problem that I cannot solve is that of the free product that must be invisible and not allow to be purchased individually. 回答1: Based on Auto add to cart a

Charge a conditional Delivery fee in WooCommerce 3

一世执手 提交于 2021-02-08 09:01:05
问题 This is my condition like: If subtotal <= certain amount && subtotal <= certain amount So if the subtotal matches this criteria then I want to charge a delivery fee which should also show in the email invoice. Currently this is my code: add_action( 'woocommerce_cart_calculate_fees','my_delivery_fee' ); function my_delivery_fee() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $subtotal = $woocommerce->cart->subtotal; if(subtotal <= certain amount && subtotal <=

WooCommerce promotional discount: Buy 10 Get 1 Free

守給你的承諾、 提交于 2021-02-08 08:36:16
问题 I'm trying to set up a specific discount for three variable products (464, 465 and 466). If a customer buys ten products they get one for free. Based on WooCommerce discount: buy one get one 50% off answer code, I've come up with the following code: add_action('woocommerce_cart_calculate_fees', 'add_custom_discount_11th_at_100', 10, 1 ); function add_custom_discount_11th_at_100( $wc_cart ){ if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $discount = 0; $items_prices = array(); // Set

Add product description to cart items in Woocommerce

 ̄綄美尐妖づ 提交于 2021-02-07 19:42:07
问题 I'm struggling to find a simple solution to this problem I'm having with One-page-checkout plugin for Woocommerce. My client would like to add the product description next to the product title in cart items. Any thoughts on how I can manipulate the code to show the description? This is what I have actually: I would think that this plugin would just be hiding the description somewhere but I can't locate it anywhere in the code. 回答1: There is 2 ways to do it (making work for products and

Save and display order item custom meta data in Woocommerce

倾然丶 夕夏残阳落幕 提交于 2021-02-07 09:52:36
问题 I have some custom code was working perfectly and since I have updated Woocommerce to version 3.5.2 it is not working anymore, not sure if it is because I changed the wordpress theme or because because plugin updates. My problem is that the value of the custom fields doesn't appear on the order page from woocommerce or even on the order email. Here is the related code: // Display Fields using WooCommerce Action Hook add_action('woocommerce_product_options_general_product_data', 'woocom

Save and display order item custom meta data in Woocommerce

别说谁变了你拦得住时间么 提交于 2021-02-07 09:51:47
问题 I have some custom code was working perfectly and since I have updated Woocommerce to version 3.5.2 it is not working anymore, not sure if it is because I changed the wordpress theme or because because plugin updates. My problem is that the value of the custom fields doesn't appear on the order page from woocommerce or even on the order email. Here is the related code: // Display Fields using WooCommerce Action Hook add_action('woocommerce_product_options_general_product_data', 'woocom

Save and display order item custom meta data in Woocommerce

我是研究僧i 提交于 2021-02-07 09:51:30
问题 I have some custom code was working perfectly and since I have updated Woocommerce to version 3.5.2 it is not working anymore, not sure if it is because I changed the wordpress theme or because because plugin updates. My problem is that the value of the custom fields doesn't appear on the order page from woocommerce or even on the order email. Here is the related code: // Display Fields using WooCommerce Action Hook add_action('woocommerce_product_options_general_product_data', 'woocom

Add an additional cost to flat rate shipping each 3 items in Woocommerce

百般思念 提交于 2021-02-07 06:38:28
问题 I'm running a woocommerce shop and using a Flat Rate shipping $15 . I have written a formula to add $1.25 for each additional item. 13.50 + ( 1.25 * [qty]) Sipping "flat rate settings | $1.25 for Additional Each Item: But I want to add this cost $1.25 for every 3 items. I mean 3, 6, 9, 12 and so on... Can anyone tell me how to do this? Any help is appreciated. 回答1: Updated (2021) The following code will add an additional cost to flat rate shipping method each 3 items (3, 6, 9 …) . You will