Needs review
Project:
Commerce Price Table
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Mar 2012 at 17:39 UTC
Updated:
21 Dec 2013 at 02:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nicodh commentedHi,
I'm very interesting in this feature, is this possible with this module ? If maintaners need help, I'm going to use this module for a commercial project which needs this feature, so of course I'm OK to bring my contribution !
Thanks
Comment #2
nicodh commentedI have looked the code, and I search a way to pass line items to the rule action commerce_price_table_set_price, and then calculate price with a kind of "context" : order's line items.
An idea ?
Comment #3
Cybso commentedUsing a join on field_data_commerce_display_path in commerce_price_table_set_price (commerce_price_table.rules.inc) does the trick:
Update: Removed third parameter $price_table from the patch. I diff'ed it against my patch from http://drupal.org/node/1875688.
Comment #4
mattnorman2003 commentedoh excellent, i'd forgotten about this but would still be useful, thanks Cybso, will test it out ASAP.
Comment #5
mattnorman2003 commentedTested and works exactly as required, thanks a lot.
Comment #6
Cybso commentedI've added a boolean parameter to the rules action to enable or disable this behavior.
Comment #7
Cybso commentedWhoops... try this one ;-)
Comment #8
Cybso commentedAnd here's the same patch against "Expose price table to rules".
Comment #9
mattnorman2003 commentedOK I have come across a stumbling block here, this solution works perfectly when creating orders through the shopping cart but doesn't work when creating an order manually through the back end.
Initially the price table didn't function at all when creating an order through the back end so I am using this module here ( http://drupal.org/project/commerce_checkout_admin ) to allow the rules that update prices from the price table to fire when an order is saved through the back end.
The reason it doesn't work is that $line_item->commerce_display_path is empty when not creating an order using the shopping cart, I'm not sure how to get around this.
Comment #10
Cybso commentedThis is not easy, and since each product can be referred by multiple displays not intended by me (I only wanted to group all products of the same display).
I think it must be possible to join on field_data_commerce_product.entity_id (instead of field_data_commerce_display_path) and use the product_id to join on field_data_field_product.field_product_product_id to retrieve other products within the same displays (field_data_field_product.entity_id). This should be doable within one single SQL statement.
Comment #11
mattnorman2003 commentedThanks for the pointers - will give that a go.
Comment #12
mattnorman2003 commentedok this it what I have now - my php skills and knowledge of the commerce tables are pretty flaky so I suspect it's not very elegant but it seems to work!
Comment #13
pcambraJust a recommendation, use EntityFieldQuery instead, you're doing too much db query assumptions there
Comment #14
T.Mardi commentedHi Pedro, thanks for this great module.
I need this functionality and just wanted to check what patch I should be applying and testing?
I'm not sure what EntityFieldQuery is and how to add that to number #12.
Could you help please?
Thank you.
Comment #15
aaronglamb commentedComment #16
aaronglamb commentedI didn't use an EFQ, but above is a patch against the current release (7.x-1.1).