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
https://forums.phpfreaks.com/topic/259775-how-to-get-my-seassignedorderid/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.