1

We want to offer the ability for customers to buy virtual gift cards, and also virtual/physical combined gift cards on our e-commerce site.

My question relates to how we would manage the physical gift cards. One way could be to download a whole gift card pool of codes, so that we can have them printed onto some cards and store them at the warehouse in the same order as they would be sold on the website. I cannot work out how to export the whole gift card pool, however. Is there a way or are we taking the wrong approach to this?

2

We implemented once a API which just creates a code and stores it with the order-item, so you know inside of the order, what code for which gift card.

So I recommend to implement an observer for order_item_save_before which checks for the product and whether there is NO id, if it is the case, than generate a new code and add it as product option, so it is automatically visible everywhere

You want to implement an observer, listening to sales_order_item_safe_before: Fatal error: Call to a member function getData() on a non-object

Then you want to check for the settings:

protected $_eventObject = 'item';

to know how the parameter is named.

Then you implement your observer:

public function salesOrderItemSafeBefore(Varien_Event_Observer $observer) {
$item = $observer->getItem();

    // checke whether product is of the type you want and item has no id
    if($item->isObjectNew() && $item->getProduct()->getSku() == 'whatever_the_sku_is') {
        // get one code or generate one and attach as option
        ->getProductOption()
        // add option
        ->setProductOption()
    }
}

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.