M
M
Maxim Tyulpakov2018-09-10 17:45:58
WordPress
Maxim Tyulpakov, 2018-09-10 17:45:58

How to swap the price of a variable product?

When choosing a variable product, the price changes depending on the color. It is necessary that the price be displayed at the top, because. below it is not always visible.
How to do this, despite the fact that when choosing a regular (not variable) product, the price is in the right place.
5b9683560c906993602465.png
Is it possible to remove this variable price from the product card at all?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
its2easyy, 2018-09-11
@MaXComp

If you know how to work with WordPress hooks, you can try to move this price up. You need to remove the woocommerce_single_variation function that adds an empty block for the price from the woocommerce_single_variation action and add it somewhere else in the variation form because the woocomers js only expects the price there. More or less like this

remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation', 10);
add_action( 'woocommerce_before_variations_form', 'woocommerce_single_variation', 20);

The file in which you can see what is called where is single-product/add-to-cart/variable.php. You can hide a static price only in a variable product using css, if necessary, check the type of product and hang an additional class.

V
Vakshgt, 2020-12-19
@Vakshgt

To completely remove the price range.

add_filter( 'woocommerce_variable_sale_price_html', 'my_remove_variation_price', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'my_remove_variation_price', 10, 2 );
 
function my_remove_variation_price( $price ) {
$price = '';
return $price;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question