-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Notice] Undefined property: OrderDiscountModifier::$Amount when adding to cart #93
Comments
Can you try 1.3 of Discounts? |
I just tried that and it gives the same error. |
@wilr any other advise or help? |
@adrian-stein What is line 50 of your OrderDiscountModifier? The |
https://github.com/silvershop/silvershop-discounts/blob/1/code/modifiers/OrderDiscountModifier.php#L45 is the line causing issues. It is really line 45 that is causing issues. I had some debug lines in the code to see if I could see what was happening which changed the error line. so I changed it to |
|
Yes Could it have something to do with the fact that Doing I even tried adding a new field named |
@wilr any more bright ideas? Is this issue just or me or do others have issues with this module and PHP 7.1? |
I've setup a test project on PHP 7.1.23 using the below. "silvershop/core": "^1.3", And I can add a product fine to the cart. Perhaps could you provide more detail on your discount that you have setup? Any other extensions or custom code? |
@adrian-stein Try the following patch in the discounts module.
|
@wilr If I remove the getAmount() function I can add stuff to the cart. I am not sure if all discounts and what not work correctly with that removed though. If I just replace In terms of other shop modules I use the following
I have 4 discounts in the database but none are active. Does having none active discounts affect it, or do they not do anything if they are set like that. |
I tested it with the |
Awesome. Thank you very much. |
I am using "silvershop/core": "1.3.0" and "silvershop/discounts": "1.2.0", old I know but it works for my client.
I just upgraded the server from PHP 7.0 to 7.1 and now it shows this error when I try and add a product to the cart. See the full error below. Any ideas what might be gong on. If i switch back to 7.0 the site runs fine.
[Notice] Undefined property: OrderDiscountModifier::$Amount
GET /products/locks-and-latches/over-centre-catches/adjustable-stainless-steel/ojop-701s-ass-ss-over-centre-catch-non-locking/
Line 3048 in C:\Nimbler\ovesco\framework\model\DataObject.php
Source
3039 $val = get_class($this);
3040 return DBField::create_field('Varchar', $val, $fieldName);
3041
3042 } else if(array_key_exists($fieldName, self::$fixed_fields)) {
3043 return DBField::create_field(self::$fixed_fields[$fieldName], $this->$fieldName, $fieldName);
3044
3045 // General casting information for items in $db
3046 } else if($helper = $this->db($fieldName)) {
3047 $obj = SS_Object::create_from_string($helper, $fieldName);
3048 $obj->setValue($this->$fieldName, $this->record, false);
3049 return $obj;
3050
3051 // Special case for has_one relationships
3052 } else if(preg_match('/ID$/', $fieldName) && $this->hasOneComponent(substr($fieldName,0,-2))) {
3053 $val = $this->$fieldName;
3054 return DBField::create_field('ForeignKey', $val, $fieldName, $this);
Trace
DataObject->dbObject(Amount)
DataObject.php:2681
DataObject->setField(Amount,0)
OrderDiscountModifier.php:50
OrderDiscountModifier->getDiscount()
OrderDiscountModifier.php:82
OrderDiscountModifier->getAmount()
ViewableData.php:120
ViewableData->__get(Amount)
DataObject.php:3048
DataObject->dbObject(Amount)
DataObject.php:2681
DataObject->setField(Amount,0)
OrderDiscountModifier.php:50
OrderDiscountModifier->getDiscount()
OrderDiscountModifier.php:27
OrderDiscountModifier->value(30)
OrderModifier.php:77
OrderModifier->modify(30)
OrderTotalCalculator.php:33
OrderTotalCalculator->calculate()
The text was updated successfully, but these errors were encountered: