price

Custom product price suffix for selected product categories in Woocommerce

泄露秘密 提交于 2019-12-20 03:01:32
问题 I would like to display a piece of text after the price tag in WooCommerce. I have a code that is working for my functions.php, but it shows on all product categories. I was wondering if someone knows how to make this custom text to show for only selected categories; or even better, unselected product categories as there are a lot more product categories that will display the text than the ones who doesn't. My actual code: add_filter( 'woocommerce_get_price_html', 'custom_price_message' );

Omitting price property for sold products?

邮差的信 提交于 2019-12-19 10:50:55
问题 I'm adding Schema.org (using Microdata) to a product page. My client wants the price omitted for sold products - she doesn't want anyone to be able to see the price of sold products. However this was showing up as an error in the Microdata for 'price': check page in Google SDTT Obviously the average user will still not be able to see the price, but it's used by Google Shopping so might show up. Should I just put a price of 0? 回答1: It’s perfectly fine to have an Offer without a price . If

Set a specific product price conditionally on Woocommerce single product page & cart

会有一股神秘感。 提交于 2019-12-19 10:07:52
问题 In Woocommerce I would like to alter the price of a specific product (in this case with an ID of 87) on both the single product page and for related cart items. The product price needs to be increased by $10 but only on the single product page and only externally (so that the internal price or price set in Woocommerce is not altered). Additionally, this price should also be altered in the cart but only if products from a certain category are NOT also in the cart. Context: If someone buys this

WooCommerce Price overriding not working

邮差的信 提交于 2019-12-19 04:14:11
问题 I have set up a hidden input item using woocommerce_before_add_to_cart_button hook function add_gift_wrap_field() { ?>`<input type="hidden" id="price_val" name="added_price" value="100.34">`<?php } add_action( 'woocommerce_before_add_to_cart_button', 'add_gift_wrap_field' ); Saving fields against the product: function save_gift_wrap_fee( $cart_item_data, $product_id ) { if( isset( $_POST['added_price'] ) ) { $cart_item_data = array(); $cart_item_data[ "gift_wrap_fee" ] = "YES"; $cart_item

Set cart item product generated sale price only for specific products in Woocommerce

谁说胖子不能爱 提交于 2019-12-18 09:26:13
问题 Following Set only specific products sale price programmatically in WooCommerce 3, the related cart items price are not updated with the product's generated sale price. How can I get the generated sale price for specific products, in the related cart items? Any help is appreciated. 回答1: To get the right generated sale price in cart item for specific product IDs try the following: // HERE below in the array set your specific product IDs function specific_product_ids(){ return array(37, 41); //

Replace product zero displayed price with a custom text in Woocommerce 3

家住魔仙堡 提交于 2019-12-18 09:25:56
问题 I am looking for a way to replace €0,00 price for a WooCommerce (version 3.3.x) product with text, like 'Based on contract'. Preferably visible in the webshop and emails. Because of recent changes in WooCommerce the existing snippets aren't working anymore, like: add_filter('woocommerce_get_price_html', 'changeFreePriceNotice', 10, 2); function changeFreePriceNotice($price, $product) { if ( $price == wc_price( 0.00 ) ) return 'FREE'; else return $price; } Or <?php // Do not copy the opening <

Replace product zero displayed price with a custom text in Woocommerce 3

久未见 提交于 2019-12-18 09:25:11
问题 I am looking for a way to replace €0,00 price for a WooCommerce (version 3.3.x) product with text, like 'Based on contract'. Preferably visible in the webshop and emails. Because of recent changes in WooCommerce the existing snippets aren't working anymore, like: add_filter('woocommerce_get_price_html', 'changeFreePriceNotice', 10, 2); function changeFreePriceNotice($price, $product) { if ( $price == wc_price( 0.00 ) ) return 'FREE'; else return $price; } Or <?php // Do not copy the opening <

Conditionally alter specific product price in Woocommerce

谁说我不能喝 提交于 2019-12-18 09:19:08
问题 I would like to alter a specific product in Woocommerce, adding programmatically to its original an amount of $10, EXCEPT in those cases : On specific product pages that are bookable products for hire (Woocommerce Bookings) that belongs to a certain Category "C". If any cart item belongs to that category "C". I was using this answer code to one of my questions until now. But I should need to display this specific product altered price everywhere except on that product pages that are bookable

Adding custom text labels to the prices when products are on sale

余生长醉 提交于 2019-12-17 20:53:57
问题 On WooCommerce product single pages, if a product owns a sales price, the normal price is crossed out and behind it, the sale price is highlighted. My question: How can I add a label like "Old Price: XX Dollar" and "New Price: XX Dollar" instead of only the crossed out and the new price (sale price)? 回答1: Update 2 (for simple and variable products + solved the bug on same variations prices) when products are on sale, you can add custom labels just as you want using a custom function hooked in

Set cart item price from a hidden input field custom price in Woocommerce 3

為{幸葍}努か 提交于 2019-12-17 16:55:09
问题 In Woocommerce, I used jQuery to calculate a custom price on a single product pages, and now need to pass this value to the cart. The desired behavior is to pass the new price retrieved from the hidden field to the cart item price. Here is my actual code: // Hidden input field in single product page add_action( 'woocommerce_before_add_to_cart_button', 'custom_hidden_product_field', 11, 0 ); function custom_hidden_product_field() { echo '<input type="hidden" id="hidden_field" name="custom