I am working on Porto WordPress theme. I want to display product variation price if visitor select different color, each color will have a price. for example.
Product normal price: Regular :$200 Sale: $180
On Black Color Selection: that will add extra $20 Regular price: $220 Sale Price: $200
I have try many plugins but its not working.
Example Page: https://www.leatherjacketmaster.com/mens-leather-jackets/mens-biker-leather-jackets/elegant-men-s-red-leather-jacket-voteporix
If you click on any color it will update the price and add extra $20 and also there is strike through.
How it can be achieve that function in WordPress ?
You can apply your custom price from below hook please check below example of my code:
function opal_varient_price( $price, $variation ) {
if ( $variation->product_type == 'variation' ) {
$user = $user ? new WP_User( $user ) : wp_get_current_user();
$role = $user->roles[0];
if($role == 'detailer'){$pricex = get_post_meta( $variation->variation_id, 'dist',true);}
else if($role == 'reseller'){$pricex = get_post_meta( $variation->variation_id, 'res',true);}
else{ $pricex = $price;}
}
return $pricex;
}
add_filter( 'woocommerce_product_variation_get_regular_price', 'opal_varient_price' , 99, 2 );
add_filter( 'woocommerce_product_variation_get_sale_price', 'opal_varient_price' , 99, 2 );
add_filter( 'woocommerce_product_variation_get_price', 'opal_varient_price', 99, 2 );