1

trying to divide two attributes by each other to get the value of Price Per unit.

 <?php echo $this->escapeHtml( $_item->getFinalPrice() / $_item->getPackSize()) ?>

Not sure what im missing but it shows blank on the frontend. any help is appreciated.

Simplified: When i enter a Price and I enter the custom attribute "Pack Size" and save the Price per piece should populate automatically.

Price / Packsize = price per piece

1 Answer 1

1

Probably one of the factors are not a number so the division can not be done. First of all, check that these two lines return the numbers you expect:

echo $_item->getFinalPrice()
echo $_item->getPackSize()

You'll probably find the second one is empty. Maybe because the pack_size attribute is not loaded in the page you are looking at.

Also, notice that you don't need to call $this->escapeHtml here. It is supposed that you are passing a number to escapeHtml, so there should be no html to escape.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.