price

Change price of product in WooCommerce cart and checkout

前提是你 提交于 2019-12-05 13:20:24
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 Ce right hook to get it working is woocommerce_before_calculate_totals . But you will have to complete (replace) the code to get the new price in the hooked function

Display Woocommerce product price with and without tax and tax amount

本秂侑毒 提交于 2019-12-04 19:08:20
问题 I am using WooCommerce for WordPress and I'm listing items excluding Tax. I need to show separately the Price (without tax) , the Tax and the PRICE + Tax on the product page (like in checkout page) . I have not been able to find a plugin that does this. How can I do this? 回答1: WooCommerce v3.0.0 and Later As of WooCommerce version 3.0, the function woocommerce_price() is deprecated, as is the method get_price_including_tax(). Instead, you should use wc_get_price_including_tax: <?php echo wc

Set programmatically product sale price and cart item prices in Woocommerce 3

半腔热情 提交于 2019-12-04 05:35:44
问题 This is the continuation of : Set product sale price programmatically in WooCommerce 3 The answer works, however once a user adds the product to cart, the old price still shows up on checkout. How to get the correct sale price on cart and checkout pages for cart items? Any help is appreciated. 回答1: The missing part to get it work for for cart and checkout pages (and also Orders and email notifications too) is a very simple trick: add_action( 'woocommerce_before_calculate_totals', 'set_cart

Replace WooCommerce variable products price range with the min price

女生的网名这么多〃 提交于 2019-12-04 05:30:40
问题 With my Woocommerce webshop, I sell services using variable products and I would like to replace the price range by "Prices starting at" ++ the lowest price. I have tried changing the code in many ways but I didn't get it working. How can I hide price range in Woocommerce and show only the lowest one on variable products? 回答1: The following will replace the variable price range by "Prices starting at" with the lowest price: add_filter( 'woocommerce_variable_sale_price_html', 'custom_variable

Add the variation price to variable product dropdown item names in Woocommerce

断了今生、忘了曾经 提交于 2019-12-02 12:22:45
问题 I'm using this code to get the variable product options $terms = wc_get_product_terms( $bundle_product_id, $name, array( 'fields' => 'all' ) ); foreach ( $terms as $term ) { if ( !in_array( $term->slug, $options ) ) { continue; } echo '<option value="' . esc_attr( $term->slug ) . '" ' . selected( sanitize_title( $selected_value ), sanitize_title( $term->slug ), false ) . '>' . apply_filters( 'woocommerce_variation_option_name', $term->name ) . '</option>'; } I tried a lot of codes to get

Set only specific products sale price programmatically in WooCommerce 3

守給你的承諾、 提交于 2019-12-02 10:39:44
问题 I would like to Set product sale price programmatically in WooCommerce 3 but only for specific products Ids. Is it possible and how can I target only specific products using this thread code? I haven't be able to make it work for specific products only. Any help is appreciated. 回答1: To Set only specific product sale price (the products IDs are defined in the 1st function) , try this: // HERE below in the array set your specific product IDs function specific_product_ids(){ return array(37, 43,

Conditional custom output around products sale price and regular price

谁都会走 提交于 2019-12-02 09:56:02
问题 I'm trying to work on a custom conditional output where when a product loop is found with sales price, it adds a class to the sale price tag. If there's only regular price, it adds this class to regular price tag. I can't seem to get this to work after looking on & off from different documentations: add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 ); function custom_price_html( $price, $product ){ ob_start(); global $product; if (isset($product->sale_price)) { return str

Conditional product prices cart issue in WooCommerce 3

蓝咒 提交于 2019-12-02 05:24:48
问题 I modified a function to create custom prices for some of my members i.e. the normal price is $1 but if you're a bronze member it's $2, a silver member $3, etc. The prices are changed on the shop and single product page. When the product is added to the cart, however, the price reverts to the original amount. Is there additional code I should be including to have the price accurately changed all the way through checkout and billing? // Variations (of a variable product) add_filter(

Sort a Woocommerce product variations custom output by their price

蹲街弑〆低调 提交于 2019-12-02 05:00:59
问题 Bellow I have a custom shortcode function based on this answer code that displays a block of product data for both Simple products and each variation of a Variable product. The output of the variation blocks seems to be ordered by the ID of the variation itself. For example, this is a screenshot of the frontend output: Which you can see matches the order of the variation IDs (from smallest to largest) screenshot: What I would like is to sort the variations by their prices instead (NOT by

Conditional product prices cart issue in WooCommerce 3

不问归期 提交于 2019-12-02 02:18:47
I modified a function to create custom prices for some of my members i.e. the normal price is $1 but if you're a bronze member it's $2, a silver member $3, etc. The prices are changed on the shop and single product page. When the product is added to the cart, however, the price reverts to the original amount. Is there additional code I should be including to have the price accurately changed all the way through checkout and billing? // Variations (of a variable product) add_filter('woocommerce_variation_prices_price', 'custom_variation_price', 99, 3 ); add_filter('woocommerce_variation_prices