Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Thanks for building this great commerce add-on. In a view on which I use your module I got this using commerce_discount:
Notice: Undefined index: discount-[discount-rule-name] in commerce_price_components_handler_area_order_total->render() (regel 47 van commerce_price_components/includes/views/handlers/commerce_price_components_handler_area_order_total.inc).
Can you help me please?
I have a discount rule active!
Greetings, Martijn
Comment | File | Size | Author |
---|---|---|---|
#5 | commerce_price_components-undefined-index-discount-2156989-5.patch | 3.78 KB | GoZ |
Comments
Comment #1
Summit CreditAttribution: Summit commentedHi,
Will this work:
Instead of:
Then the error is gone, but is it the same functionality please?
greetings, Martijn
Comment #2
liupascal CreditAttribution: liupascal commented#1
if (empty($this->options['commerce_price_components'][$component['name']])) {
Check if the value is empty or not (http://www.php.net/manual/fr/function.empty.php)while
if (!$this->options['commerce_price_components'][$component['name']])) {
will check if it returns false.I think the issue here is that it actually try to match price component "types" (base_price, discount, fee, shipping....) with the actual price component names.
In discount for instance, $component['name'] will return "discount-Name of your discount" while it will be under the key "discount" in the $this->options['commerce_price_components'] object.
In the current version of -dev we have the following code :
I think the problem here remains the same, as it will try to compare the component type "discount" to "discount - My discount".
Not sure how this should be handled though, as tax price component are named like "tax|myTaxName", and discounts as "discount - myDiscountName"
In another module I used a strpos() to search for tax or discount, what do you think ?
Comment #3
liupascal CreditAttribution: liupascal commentedPatch attached
Comment #4
joelpittetThese are unnecessary changes.
couldn't this be a simple empty() check?
Comment #5
GoZ CreditAttribution: GoZ at Centarro commentedBy default, component name for discounts is not 'discount - Discount Name' but 'discount|Discount Name'.
Pipe is used to separate keys in array keys, and is used in different case like with taxes, so should be the convention.
Here is a patch to take care of that.
Comment #6
kevster CreditAttribution: kevster commentedMany thx @goz - cleared the error for me...
Comment #7
kevster CreditAttribution: kevster commentedI have just applied this patch to a site and it works by showing discounts in the cart again but knocks out the VAT element in the cart so no VAT is applied anywhere?
Im using 20% VAT (UK), price by components and commerce order (component) to calc totals as it gives more flexibility - I have VAT ticked.
Without the patch I get VAT and no discounts showing - with the patch I get discounts line showing but no VAT?
EDIT:
This could be because VAT is used like $component_types['tax|vat'] ?
Comment #8
james.williams CreditAttribution: james.williams at ComputerMinds commented