Change Price Of All Product to $0 On Click Add To Cart Button
-
So I added a second add to cart button to a variable product.
https://www.stagingdomain.xyz/product/sap-tools/
I created a duplicate variable product add to cart button php file: single-product/add-to-cart/variation-add-to-cart-button2.php
—–> The goal is to make the second add to cart button add the products to the cart with everything at $0 regardless of price. It will act as a “quote button” because I already have “$0” text changed to “Quote”.
How can I accomplish that?
———-
Edit variation-add-to-cart-button2.php? Maybe use some form of: return $price * 0;
or
apply filter on click of button two?
// Variable
add_filter(‘woocommerce_product_variation_get_regular_price’, ‘custom_price’, 99, 2 );
add_filter(‘woocommerce_product_variation_get_price’, ‘custom_price’ , 99, 2 );// Variations (of a variable product)
add_filter(‘woocommerce_variation_prices_price’, ‘custom_variation_price’, 99, 3 );
add_filter(‘woocommerce_variation_prices_regular_price’, ‘custom_variation_price’, 99, 3 );function custom_price( $price, $product ) {
// Delete product cached price (if needed)
wc_delete_product_transients($product->get_id());return $price * 0; // X3 for testing
}function custom_variation_price( $price, $variation, $product ) {
// Delete product cached price (if needed)
wc_delete_product_transients($variation->get_id());return $price * 0; // X3 for testing
}
- The topic ‘Change Price Of All Product to $0 On Click Add To Cart Button’ is closed to new replies.