To display variable product price as a single value, add the following code to the functions.php
file in theme. After adding the code, the price of the cheapest variant with the prefix “From” will be presented on all pages except the product page.
Several modifications can be made to the code:
- In order for the price in this form to be displayed on every subpage, the condition
if ( !is_singular( 'product' ) ) {
should be deleted: lines 3 and 18 should be removed. - You can change the content of the prefix and optionally add the content of the suffix: lines 8 and 9
- As the displayed price, you can use the maximum price or one of the regular prices: on line 16, change
$min_price
to the required price.
If you do not use the child theme, remember that changes made to the functions.php
file will be overwritten when the theme is updated.
While copying code to functions.php
file it is not nessesary to copy <?php
opening tag.