Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change variation price range when using Show Single Variations
<?php
/**
* Change variation price to parent.
*
* Implement this: https://iconicwp.com/blog/change-price-range-variable-products-woocommerce/
* When using this plugin: https://iconicwp.com/products/woocommerce-show-single-variations/
*
* @param float $price
* @param obj $product
*
* @return str
*/
function iconic_variation_price_html( $price, $product ) {
if( ! $product->is_type( 'variation' ) ) {
return $price;
}
if( is_product() || is_cart() || is_checkout() ) {
return $price;
}
$parent = wc_get_product( $product->get_parent_id() );
return $parent->get_price_html();
}
add_filter( 'woocommerce_get_price_html', 'iconic_variation_price_html', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.