Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * make all products price to zero
- */
- add_filter('woocommerce_product_get_price', 'dctit_set_products_price_to_zero', 99, 2 );
- add_filter('woocommerce_product_get_regular_price', 'dctit_set_products_price_to_zero', 99, 2 );
- add_filter('woocommerce_product_get_sale_price', 'dctit_set_products_price_to_zero', 99, 2 );
- // Variations
- add_filter('woocommerce_product_variation_get_regular_price', 'dctit_set_products_price_to_zero', 99, 2 );
- add_filter('woocommerce_product_variation_get_price', 'dctit_set_products_price_to_zero', 99, 2 );
- add_filter('woocommerce_product_variation_get_sale_price', 'dctit_set_products_price_to_zero', 99, 2 );
- function dctit_set_products_price_to_zero ( $price, $product ) {
- //remove cached prices
- //wc_delete_product_transients( $product->get_id() );
- $price = 0;
- return $price;
- }
- //variable products
- add_filter('woocommerce_variation_prices_price', 'dctit_set_variable_products_price_to_zero', 99, 3 );
- add_filter('woocommerce_variation_prices_regular_price', 'dctit_set_variable_products_price_to_zero', 99, 3 );
- add_filter('woocommerce_variation_prices_sale_price', 'dctit_set_variable_products_price_to_zero', 99, 3 );
- function dctit_set_variable_products_price_to_zero ( $price, $variation, $product ) {
- //remove cached prices
- //wc_delete_product_transients( $product->get_id() );
- $price = 0;
- return $price;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement