Guest User

Untitled

a guest
Jun 22nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public function setExpirationDate($observer)
  2. {
  3.  
  4. if($this->remainingdays != null) {
  5. $remainingdays = $this->remainingdays;
  6. } else {
  7. $remainingdays = 0;
  8. }
  9. $order = $observer->getEvent()->getOrder();
  10. foreach ($order->getAllItems() as $item)
  11. {
  12.  
  13. $prdEntyId = $item->getData("product_id");
  14. $product = Mage::getModel('catalog/product')->load($prdEntyId);
  15. $prdAtrSetId = $product->getData("attribute_set_id");
  16. $trailOption = $product->getData("trialsubsription");
  17. $subLength = $product->getData("subscriptionlength");
  18. error_log("Values are : product id -->".$prdEntyId."Product Attribute set Id ->".$prdAtrSetId."Trail Option".$trailOption."Subscripion lenght->".$subLength);
  19. if($prdAtrSetId == '32' && $trailOption == '0')
  20. {
  21. $expiryDate = date('Y-m-d H:i:s', mktime(0, 0, 0, date("m") , date("d") + $subLength + $remainingdays, date("Y")));
  22. $quote = $observer->getEvent()->getQuote();
  23. $observer->getEvent()->getOrder()->setExpirationdate($expiryDate);
  24. $observer->getEvent()->getOrder()->setTrialsubsription($trailOption);
  25. error_log('coming upto order saved attributes');
  26. $quote->setExpirationdate($expiryDate);
  27. $quote->setTrialsubsription($trailOption);
  28. error_log('coming upto quote saved attributes');
  29. $order->save();
  30.  
  31. }
  32.  
  33.  
  34. }
  35.  
  36. return $this;
  37. }
Add Comment
Please, Sign In to add comment