D
D
derekua2021-09-09 15:58:15
WordPress
derekua, 2021-09-09 15:58:15

How to add another price (for info) below the price with an attribute dependency?

There is a store, he has goods with a price per pack. In pack N pcs. It is necessary to display the information price (price per piece) under the main one (in the product and basket) with the logic:

Price per piece = Price / attribute "quantity in pack"

while the quantity in the package is indicated not only by numbers, for example: 10 kg , 10 pieces. And the output is important for those products that have a value in a similar attribute.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anonimmus, 2021-09-10
@Anonimmus

$price = $product->get_sale_price();
$newPrice = $price / get_attribute('ваш атрибут');
echo $newPrice. " шт" ;

Here it is also necessary to register a check for the presence of attributes. That is, pcs or kg for this product.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question