product

Hide payment method based on product type in WooCommerce

↘锁芯ラ 提交于 2021-02-16 03:56:00
问题 In WoCommerce, I would like to disable particular payment methods and show particular payment methods for a subscription products in WooCommerce (and vice versa). This is the closest thing we've found but doesn't do what I am expecting. Yes, there are plugins that will do this but we want to achieve this without using another plugin and without making our stylesheet any more nightmarish than it already is. Any help on this please? 回答1: Here is an example with a custom hooked function in

Hide payment method based on product type in WooCommerce

帅比萌擦擦* 提交于 2021-02-16 03:54:00
问题 In WoCommerce, I would like to disable particular payment methods and show particular payment methods for a subscription products in WooCommerce (and vice versa). This is the closest thing we've found but doesn't do what I am expecting. Yes, there are plugins that will do this but we want to achieve this without using another plugin and without making our stylesheet any more nightmarish than it already is. Any help on this please? 回答1: Here is an example with a custom hooked function in

Woocomerce Remove a specific cart items when adding to cart another specific items

余生颓废 提交于 2021-02-13 05:47:26
问题 Provided solution here Remove a specific cart item when adding to cart a specific product in Woocommerce works perfect for one product id. Is any way to do this for multiple id's? 回答1: Update 2 : The following code will work for multiple product IDs: add_action( 'woocommerce_add_to_cart', 'check_product_added_to_cart', 10, 6 ); function check_product_added_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data) { // Set HERE your targeted product ID $target

Woocomerce Remove a specific cart items when adding to cart another specific items

て烟熏妆下的殇ゞ 提交于 2021-02-13 05:44:00
问题 Provided solution here Remove a specific cart item when adding to cart a specific product in Woocommerce works perfect for one product id. Is any way to do this for multiple id's? 回答1: Update 2 : The following code will work for multiple product IDs: add_action( 'woocommerce_add_to_cart', 'check_product_added_to_cart', 10, 6 ); function check_product_added_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data) { // Set HERE your targeted product ID $target

Woocomerce Remove a specific cart items when adding to cart another specific items

穿精又带淫゛_ 提交于 2021-02-13 05:43:29
问题 Provided solution here Remove a specific cart item when adding to cart a specific product in Woocommerce works perfect for one product id. Is any way to do this for multiple id's? 回答1: Update 2 : The following code will work for multiple product IDs: add_action( 'woocommerce_add_to_cart', 'check_product_added_to_cart', 10, 6 ); function check_product_added_to_cart($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data) { // Set HERE your targeted product ID $target

Display WooCommerce custom product field meta data in Cart and on Checkout

南笙酒味 提交于 2021-02-10 23:39:52
问题 I've created a custom product field (admin). The field works fine and it saves the data just fine. What I am having problems with it is adding the meta data to the cart and checkout. I get no errors (debug turned on in wp-config ), no notices -- nothing. In the cart and on checkout, no data is shown. This is my code: add_action( 'woocommerce_product_options_general_product_data', 'product_delivery_time' ); function product_delivery_time(){ global $woocommerce, $post; echo '<div class="product

Display specific product attribute in Woocommerce single product pages below price

余生长醉 提交于 2021-02-10 19:35:26
问题 In woocommerce, If a specific product attribute has a value, then I would like to display its corresponding text/value on product single product pages under the price. How to check if a specific product attribute has a value? How to get a specific product attribute name and value to display it in single product pages? 回答1: The following will display a specific product attribute label name + values under the price in single product pages only if it has a value. This can be done using WC

Add a custom “Sale Price” column to admin products list in Woocommerce

那年仲夏 提交于 2021-02-10 15:56:08
问题 I am trying to add a Sale Price column to admin Products list in Woocommerce. Here is my code: add_filter( 'manage_edit-product_columns', 'onsale_product_column', 10); function onsale_product_column($columns){ $new_columns = []; foreach( $columns as $key => $column ){ $new_columns[$key] = $columns[$key]; if( $key == 'product_cat' ) { $new_columns['onsale'] = __( 'Sale Price','woocommerce'); } } return $new_columns; } add_action( 'manage_product_posts_custom_column', 'onsale_product_column

Get specific product attribute name and value for each WooCommerce variation of a variable product

我的梦境 提交于 2021-02-10 14:36:39
问题 In WooCommerce, I would like to display variable products with my own custom design as a carousel of product variations. I got the code by which I can display the regular price of the product in array but I stuck in getting attribute name and value in that. Based on "WooCommerce variable products: Display some variations values in an HTML table" answer code, here is my actual code: add_action( 'woocommerce_before_single_product_summary', 'custom_table_after_single_product' ); function custom

Allow add to cart 3 products max for a specific product category in Woocommerce

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 06:41:36
问题 I am trying to send out a maximum of 3 free samples to customers with free shipping. I have created some 0 priced product and set them in "samples" product category. This specific products have option "sold individually" so customers can only have one of each sample. I cannot figure out how to allow only a maximum of 3 samples products from this product category on cart. Any help is appreciated. 回答1: This can be done easily using woocommerce_add_to_cart_validation action hook to limit