0

I have applied VAT to products, However, I would need to be able to overwrite the VAT amount when certain conditions are met From this question I was able to remove the tax that is automatically calculated, by using addTotalAmount to add the same amount as the VAT but multiplies by -1.

I am unsure how to get the individual product ids to be able to get their cost price.

EDIT: I was able to get the product ids with:

    $quote = $observer->getData('quote');
    $itemsList = $quote->getItemsCollection();

    foreach ($itemsList as $item){
        $item->getProductId();          
    }

However, some of the products will also have a custom price set in the backend if an order is added manually. I am unable to get that price at the moment.

0

I managed to solve this by getting the quote data with:

$quote = $observer->getData('quote');

and then get the item collection from the quote

$itemsList = $quote->getItemsCollection();

Next I went through all the items and got the item product id and price, the getPrice() will return whatever amount the price set in the Custom Price box.

foreach ($itemsList as $item){
    $item->getProductId();          
    $item->getPrice();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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