Jump to content

How to get my seAssignedOrderID


danjapro

Recommended Posts

 

This is my order form that produce my coupon code and stores it in DB.

 

I can get all my fields but this field line 198 If you look at the entire code. I am gathering all the information form the order, but this setAssignedOrderId is placeing the value 1 in DB table field.

 

$externalCoupon->setAssignedOrderId($couponeOrderId);

 

private function getExternalCoupon($extCouponKey) {




		// Used to Set the Date Purchased of the coupon, the datetime rightnow
		// Also, gather the Order Id to join with coupon
		// MG 032012. added these features
		// $couponeOrderId = $coupon->setCodeType($externalCoupon->getOrderId());
		$coupon = Mage::getModel('coupon/coupon');
	    $couponeOrderId = $this->generateCoupons($coupon->getOrderId()); 

			$rightNow = date('Y-m-d H:i:s', strtotime(Mage::getSingleton('core/date')->gmtDate()) + Mage::getSingleton('core/date')->getGmtOffset());


			// load external available coupon, limit 1, where the key matches
			$externalCoupons = Mage::getModel("coupon/external_coupon")
				->getCollection()
				->addFieldToFilter('coupon_code_group_key', array("eq" => $extCouponKey))
				->addFieldToFilter('code_status', array("eq" => 'AVAIL'))
				//->addFieldToFilter('used_dt',  array("eq" => ''))
				//->addFieldToFilter('assigned_order_id',  array("eq" => ''))						
				->setPageSize(1)
				->setCurPage(1);

			$externalCoupon = $externalCoupons->getFirstItem();
			Mage::log("Loaded external coupon for use: " . $externalCoupon->getCouponCode());





			// mark external coupon as used and save
			//MG 03-2012. added the Order ID and the Date Used to added to DB
			$externalCoupon->setCodeStatus('USED');
			$externalCoupon->setUsedDt($rightNow);	
			$externalCoupon->setAssignedOrderId($couponeOrderId);


			//echo 'Coupon Id here:' . $externalCoupon->setOrderId($item->getOrderId());

			$externalCoupon->save();

			return $externalCoupon;
		}


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.