Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function setExpirationDate($observer)
- {
- if($this->remainingdays != null) {
- $remainingdays = $this->remainingdays;
- } else {
- $remainingdays = 0;
- }
- $order = $observer->getEvent()->getOrder();
- foreach ($order->getAllItems() as $item)
- {
- $prdEntyId = $item->getData("product_id");
- $product = Mage::getModel('catalog/product')->load($prdEntyId);
- $prdAtrSetId = $product->getData("attribute_set_id");
- $trailOption = $product->getData("trialsubsription");
- $subLength = $product->getData("subscriptionlength");
- error_log("Values are : product id -->".$prdEntyId."Product Attribute set Id ->".$prdAtrSetId."Trail Option".$trailOption."Subscripion lenght->".$subLength);
- if($prdAtrSetId == '32' && $trailOption == '0')
- {
- $expiryDate = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m") , date("d") + $subLength + $remainingdays, date("Y")));
- $quote = $observer->getEvent()->getQuote();
- $observer->getEvent()->getOrder()->setExpirationdate($expiryDate);
- $observer->getEvent()->getOrder()->setTrialsubsription($trailOption);
- error_log('coming upto order saved attributes');
- $quote->setExpirationdate($expiryDate);
- $quote->setTrialsubsription($trailOption);
- error_log('coming upto quote saved attributes');
- $order->save();
- }
- }
- return $this;
- }
Add Comment
Please, Sign In to add comment