Change product prices via a hook in WooCommerce 3+

Update (December 2020) 2 code versions for themes and plugins (works in Woocommerce 3.3.x too) Cached variations prices in Woocommerce 3 (Update and addition): Now using woocommerce_get_variation_prices_hash filter hook much more efficient, instead of wc_delete_product_transients()… See this related thread Added product price filter widget hooks (see at the end). 1) Plugin version with a constructor … Read more

Create programmatically a WooCommerce product variation with new attribute values

Update January 2020: Changed to WC_Product method get_name() instead of get_title() Update September 2018: Handling taxonomy creation (Thanks to Carl F. Corneil) From a defined variable product ID You will find below, a custom function that will add (create) a Product variation. The variable parent product needs to have set for it the needed attributes. … Read more

Replace the Variable Price range by the chosen variation price in WooCommerce 3

2021 definitive update Works for WooCommerce 4+ and 5+ available on: Replace the Variable Price range by the chosen variation price in WooCommerce 4+ Update (December 2017): to avoid, Problems regarding non variable products in some themes and a repetition availability bug in some themes Note: Some plugins like the German Market or some themes … Read more

Change cart item prices in Woocommerce 3

Update 2021 (Handling mini cart custom item price) With WooCommerce version 3.0+ you need: To use woocommerce_before_calculate_totals hook instead. To use WC_Cart get_cart() method instead To use WC_product set_price() method instead Here is the code: // Set custom cart item price add_action( ‘woocommerce_before_calculate_totals’, ‘add_custom_price’, 1000, 1); function add_custom_price( $cart ) { // This is necessary … Read more

Get Order items and WC_Order_Item_Product in WooCommerce 3

If you use the get_id() method, you get your item ID which is 15 in your code. Get the product ID: The correct WC_Order_Item_Product method to get the Product Id is: get_product_id() Get the variation ID: The correct WC_Order_Item_Product method to get the variation Id is: get_variation_id() Get the order ID The correct WC_Order_Item_Product method … Read more

Forecasting by ID and Product in R [closed]

I would begin by visualizing my data to get some intuitions , detect patterns and choose the best model. R is really great for this. Here I am using ggplot2 but you can do the same thing using lattice. For example : dat$DATE <- as.Date(dat$DATE,format=”%d/%m/%Y”) library(ggplot2) ggplot(dat,aes(x=DATE,y=Rev,group=ProdCode,color=ProdCode)) + geom_line() + facet_grid(~ID) + geom_smooth(method=’lm’) Here dat … Read more