I’m having difficulty retrieving the giftcard code and amount used on an order. For example in Mage/Sales/Model/Order/Pdf/Abstract.php, there is a piece of code that works with a Sales/Order model. i.e.
($order instanceof Mage_Sales_Model_Order) is true in the PDF example
or
$order = Mage::getModel('sales/order')->load($orderID); in another example
In the invoice PDF that gets printed, the total section shows the gift card that was used as well as coupon code that was used. The coupon code can be obtained by $order->getCouponCode().
How do I get the giftcard code and amount from $order? I’ve tried
$order->getGiftcertCode();
$order->getGiftcertAmount();
but these don’t return anything. Any ideas?
There’s probably a few ways to do this, but I haven’t had to do it before so just from looking at the sales_flat_order table in the Magento database, I can see that there are a number of fields that you can use to reference different gift card amounts:
These can be accessed with the following calls:
The one you want to use is probably
$order->getGiftCardsAmount()In order to get the gift card details, they are stored as a serialised array in the “gift_cards” column of the above table. So to get that array, call
print_r $cards and you’ll see something like this:
so
should work just fine.