Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Rules integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2011 at 18:34 UTC
Updated:
14 Dec 2011 at 19:53 UTC
Its possible to remove a line item from cart (or dont add the line item) trough rules if the site date is greater than product date?
I'm stuck on action.
Event:
Before adding a product to the cartConditions:
Entity has field
Parameter: Entity: [commerce-product], Field: field_date
Data comparison
Parameter: Data to compare: [site:current-date], Operator: is greater than, Data value: [commerce-product:field-date]Action: Dindt find... (looking for something similar to: remove line item / dont add line item)
Comments
Comment #1
PedroMiguel commentedComment #2
rszrama commentedYep. In this case you'd want to use the event "Calculating the sell price of a product." Add a rule that checks the date, and if the product is no longer purchasable, it should use the action "Set the unit price to some amount" to set the price of the product to NULL - i.e. don't put anything in there, not even 0. Products with NULL prices aren't purchasable and will be removed from the Cart.
Comment #4
jdelaune commentedSorry to re-open this. I'm using the action "Set the unit price to a specific amount" but the value field is a mandatory field. So I can't leave it blank to set the value to NULL.
Is there a better way to do this?
Comment #5
jdelaune commentedComment #6
rszrama commentedAhh, yes, use the "Set a data value" action instead of the line item action. Then you can target the line item's amount column only and leave the value box empty.
Comment #7
jdelaune commentedHmm I've tried setting both 'commerce-line-item:commerce-unit-price:amount' and 'commerce-line-item-unchanged:commerce-unit-price:amount' to nothing but it still doesn't remove it from the cart. Am I setting the wrong thing?
Comment #8
PedroMiguel commentedThere is mine to you have an example:
Please note field_date is a costum field.
This work perfect.
Comment #9
jdelaune commentedStrange. This is what I have, and the code is returning true because the message gets displayed. However setting the amount to nothing doesn't seem to remove the item from the cart.
Comment #10
jdelaune commentednvm I found a way around the problem using something else.
Comment #11
PedroMiguel commented@jdelaune, please share your way, can help others...