Jump to content

CartRule.php throws Notice about undefined property


Recommended Posts

Just wondering if somebody know what I'm doing wrong:

 

			$cr = new CartRule();
			$cr->date_from = date('Y-m-d H:i:s');
			$cr->date_to =  date('Y-m-d H:i:s', (int)$this->p['expiration']);
			$cr->quantity = 1;
			$cr->quantity_per_user = 1;
			$cr->partial_use = 0;
			$cr->code = $coupon_code;
			$cr->reduction_percent = (int)$this->p['reduction'];
			$cr->highlight = 0;
			$cr->active = 1;
			$cr->name = [1=>$coupon_code];
			$cr->add();

 

This section of my code triggers an error:

Quote

Notice: Trying to get property of non-object in /home/usr/mystore.com/classes/CartRule.php on line 613

 

Line 613 in said file is trying to access this:

Context::getContext()->currency->id

 

But it's empty.

 

How can I fix this?!

I'd just set the default currency to USD but I can't seem to find anything useful about currency in context whatsoever...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...