0

$product->getPrice() is 0 for gift card product.

    $prduct_prices = null;
    foreach ($order->getAllVisibleItems() as $item) {
    $product = $item->getProduct();

    $prduct_prices[] = array(

        'price'         => $product->getFinalPrice(),
        'regular_price' => $product->getPrice(),
        'special_price' => $product->getSpecialPrice(),
    );

}
6
  • any thoughts on this ?
    – devhs
    May 27, 2021 at 12:23
  • Do you want to get gift card product ? May 27, 2021 at 12:23
  • Hello, I am getting order items from order, now i am trying to get the price of the product but with above methods on the gc product it returns 0
    – devhs
    May 27, 2021 at 12:25
  • this solution is for magento 1.9x, check if something similar exists for m2 as well. stackoverflow.com/questions/11236263/… May 27, 2021 at 12:26
  • Thanks @ManashviBirla. but $order->getGiftCardsAmount() will return the total amount of gc, i am trying to get that particular amount of price single gc product.
    – devhs
    May 27, 2021 at 12:28

1 Answer 1

0

try below code

load first order and get getGiftCards data.

$cards = unserialize($_order->getGiftCards());
    if($cards!='' && count($cards)>0) {
        foreach ($cards as $card) {
             echo $card['c'];
             echo $card['a'];
    }
}

c means - gift code

a means - gift amount

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.