price

Display a custom calculated cart item price in WooCommerce

前提是你 提交于 2020-03-24 00:37:10
问题 In WooCommerce, I'm trying to calculate the price of a variable product in the cart. I want to multiply the product price with some custom cart item numerical value. Here is my code: add_filter( 'woocommerce_cart_item_price', 'func_change_product_price_cart', 10, 3 ); function func_change_product_price_cart($price, $cart_item, $cart_item_key){ if (isset($cart_item['length'])){ $price = $cart_item['length']*(price of variation); return $price; } } The price calculation doesn't work. What I am

Adding custom text to the variation price in Woocommerce

二次信任 提交于 2020-03-23 10:58:07
问题 I thought this would have been easy, but I am stuck. All I am trying to do is add the word each after the variation price on a product page. The solution I have found adds it on the category page and in two places on the product page. The code is: /* Adds a text Each - after price */ function change_product_price( $price ) { $price .= ' each'; return $price; } add_filter( 'woocommerce_get_price_html', 'change_product_price' ); From the picture above, I only need the each added to the price

Import two CSVs in magento 2 module/extension code

和自甴很熟 提交于 2020-03-05 06:06:09
问题 First import products CSV. Then import Advance Pricing CSV. The code is running fine and I get no error. But when I check in the admin dashboard, only products are imported. And customer advance pricing is not imported. If I import the same Advance Pricing CSV manually through System -> Import -> Entity type (Advance Pricing) , it is imported successfully. Why both of these CSVs are not imported simultaneously one after the other. 来源: https://stackoverflow.com/questions/58063215/import-two

Updating product prices cache issue using a SQL query in Woocommerce

大憨熊 提交于 2020-02-23 07:33:05
问题 I have a SQL script that is supposed to synchronize and adjust regular price comparing the text document uploaded daily on server. Problem is that new prices are written to database, and I see them when looking at database. They even show in Regular price field. Problem is that frontend shows old prices. Old prices are shown on frontend untill I manually just re-update each product in backend. Since i have thousands of products it is ineffective and tedious. What am I missing? 回答1: Variable

Display custom price based on custom fields for Woocommerce simple product

泪湿孤枕 提交于 2020-01-25 03:05:13
问题 In Woocommerce, I would like update base price depending on 2 selected custom fields. With the help of LoicTheAztec I can update price of 1 custom field, so, how do a update 2 custom fields? PHP code: add_action( 'woocommerce_before_add_to_cart_button', 'custom_product_field' ); function custom_product_field() { global $product; if( $product->is_type('variable') ) return; $options = array( "" => __('Tipos'), "20.00" => "Tipo 1 + 20,00", "25.00" => "Tipo 2 + 25,00", ); woocommerce_form_field(

How to display the regular price and sale price in single product and loop pages? [duplicate]

随声附和 提交于 2020-01-16 18:27:53
问题 This question already has an answer here : Display the discounted percentage near sale price in Single product pages for WC 3.0+ (1 answer) Closed 2 years ago . I had this code in function.php of my child theme to display the regular price and sale price and it was working fine in WooCommerce v2.6.14. But this snippet doesn't work anymore on WooCommerce version 3.2.3. How can I fix that? Here is that code: add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 );

How to display the regular price and sale price in single product and loop pages? [duplicate]

别等时光非礼了梦想. 提交于 2020-01-16 18:27:29
问题 This question already has an answer here : Display the discounted percentage near sale price in Single product pages for WC 3.0+ (1 answer) Closed 2 years ago . I had this code in function.php of my child theme to display the regular price and sale price and it was working fine in WooCommerce v2.6.14. But this snippet doesn't work anymore on WooCommerce version 3.2.3. How can I fix that? Here is that code: add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 );

Add text before product price if it's higher than a specific amount in Woocommerce

前提是你 提交于 2020-01-13 20:43:28
问题 In Woocommerce I'm trying to add text before price if is higher than 59€ I tried the following code (and others one) but they didn't work: add_filter( 'woocommerce_get_price_html', 'custom_price_message' ); function custom_price_message( $price ) { if ($price>='59'){ $new_price = $price .__('(GRATIS!)'); } return $new_price; } How can I do to add (GRATIS!) text before product price if it's higher than 59? 回答1: Updated: You should try the following revisited function code: add_filter(

Add text before product price if it's higher than a specific amount in Woocommerce

佐手、 提交于 2020-01-13 20:43:23
问题 In Woocommerce I'm trying to add text before price if is higher than 59€ I tried the following code (and others one) but they didn't work: add_filter( 'woocommerce_get_price_html', 'custom_price_message' ); function custom_price_message( $price ) { if ($price>='59'){ $new_price = $price .__('(GRATIS!)'); } return $new_price; } How can I do to add (GRATIS!) text before product price if it's higher than 59? 回答1: Updated: You should try the following revisited function code: add_filter(

Display discount percentage after the selected variation sale price in WooCommerce

余生长醉 提交于 2020-01-11 07:24:09
问题 I've this code below that shows the variation selected price after the user have selected the variation add_filter( 'woocommerce_show_variation_price', 'filter_show_variation_price', 10, 3 ); function filter_show_variation_price( $condition, $product, $variation ){ if( $variation->get_price() === "" ) return false; else return true; } I need to calculate the discount percentage between the promotional price that will show and the regular price. BUT ONLY after the variation is selected, not