cart

Counting cart-items of specific product category

喜夏-厌秋 提交于 2019-12-23 20:03:39
问题 I am trying to get the number of items in the cart just from a specific product category in WooCommerce. I am doing a site for a winery. It has alcoholic and non-alcoholic products. All the wine falls under the main category of 'wine' or category id 34, with many subcategories and products underneath them. For any thing that falls under this category... I need to know how many items are in the cart under this category. If there are six bottles of wine no matter if they are all the same

Add Shipping class below each product in WooCommerce Shopping Cart page

六月ゝ 毕业季﹏ 提交于 2019-12-23 18:30:25
问题 I've configure shipping class for my products. But I want to display them below each product in the shopping cart page. Something like this : Can this be done through editing the PHP? 回答1: To display the product shipping class name in cart page, there is many ways to do it: 1) Using a custom function hooked in woocommerce_cart_item_name filter hook, this way: add_filter( 'woocommerce_get_item_data', 'shipping_class_in_item_name', 20, 2 ); function shipping_class_in_item_name( $cart_data,

Woocommerce Progressive extra cost based on total number of items in the cart

谁都会走 提交于 2019-12-23 07:10:52
问题 I am looking for some code which can make an extra charge based on the total number of items in the cart like: If number of items in cart is > 6 ===> extra cost = 5 If number of items in cart is > 12 ==> extra cost = 10 I have tried this code, but I can't get it working for my case. How can I make an extra cost based on total number of items in the cart? 回答1: Based on (this answer) WooCommerce Cart Quantity Base Discount, you can add a progressive fee based on total number of items: add

Disable shopping when an item from a specific product category is in cart in Woocommerce

早过忘川 提交于 2019-12-23 04:26:24
问题 I am trying to Disable shopping if a an item from a specific product category is in cart (which is a subscription in form of product with tabs - checkout and shipping are stripped off). When that product is added to cart, no other products should be allowed to be add up. I have tried those threads code: Disable Woocommerce add to cart button if the product is already in cart Prevent checkout for cart with specific category But didn't helped. How can I disable shopping if a specific product

Override all shipping costs for a specific shipping class in Woocommerce

霸气de小男生 提交于 2019-12-23 02:04:09
问题 I have a number of shipping classes with prices set in multiple shipping zones. Is it possible to detect if ANY product within the cart belongs to a specific shipping class, and if so set the shipping cost to 0 and display a message? I would like to use this mechanism for products which require special handling and would be shipped via freight. So if a customer's order contains any of these products the shipping quote would be provided manually post-sale. Thanks for the help. 回答1: The

Allow only one product per product category in cart

假装没事ソ 提交于 2019-12-23 01:27:09
问题 On this Question / Answer I have found the PHP code about how to just add one product per category in cart in Woocommerce. The code works just fine, but I want to add the latest added product to cart and if there is already a product of that category in the cart, I want to have the oldest deleted. add_filter( 'woocommerce_add_to_cart_validation', 'custom_checking_product_added_to_cart', 10, 3 ); function custom_checking_product_added_to_cart( $passed, $product_id, $quantity) { // HERE Type

Remove conditionally Woocommerce cart items based on a specific product

自闭症网瘾萝莉.ら 提交于 2019-12-22 18:00:16
问题 A specific WooCommerce product can only be by itself in the cart. So how do I clear the cart while adding this specific product to the cart? and how can I remove this specific product from the cart when adding any other product? I've figured out how to empty the cart when adding a specific product but I don't know how to remove this specific product from the cart when adding any other product. 回答1: The following will remove conditionally cart items based on a specific product: When the

Disable Place Order button conditionally in Woocommerce

我是研究僧i 提交于 2019-12-22 17:58:22
问题 I have some code in a function that displays a message to the end user when the total added value of a custom field exceeds a certain value. Basically its a message telling the customer that they have ordered too much furniture to fit into a 68m3 container. I also have code which is suppose to disable the add to cart button on products - this doesn't seem to work. So is there a visible issue in the code below to disable the add to cart button when my custom field total value exceeds 68 and is

Custom cart item price based on user input in Woocommerce

依然范特西╮ 提交于 2019-12-22 10:01:59
问题 in our Woocommerce store we have some minimum price for any products . And in every product inner page there is two filed where customer can type width , height of the product . And then they can add this product to cart, then price is changed based on given width and height. For example if the minimum price for a product is 50 . And customer add width =2, height=3 , then the price for this product is going to 50*2*3=300 So to arrange this we add this code to function.php add_filter(

Change price of product in WooCommerce cart and checkout

蓝咒 提交于 2019-12-22 08:16:47
问题 I'm creating a WooCommerce add-on to customize the product, based on selected options by the visitor and custom price is calculated and stored into session table also. I am able to get that value in cart page also. My problem: I would like to change the default price of the product and replace it with new calculated value in the WooCommerce process as cart, checkout, payment, mail notifications, order... Any advice please? Thanks 回答1: Ce right hook to get it working is woocommerce_before