Now I try:
1. Add to product field 'price2' (of type 'price').
2. Make pricing rule:
event: Calculating the sell price of a product
condition: User has role(s)
action: ???
What action I must use for copying price from field 'field_price2'?
1. Add a field called adminprice to the product.
2. Create a product pricing rule:
When calculating the sell price of an order
Condition: Entity has field Parameter: Entity: [commerce-line-item], Field: commerce_product
Condition: Entity has field Parameter: Entity: [commerce-line-item:commerce-product Field: field_adminprice
Condition: : User: [site:current-user], Roles: administrator
Action: Set a data value: Parameter: Data: [commerce-line-item:commerce-unit-price:amount], Value: [commerce-line-item:commerce-product:field-adminprice:amount]
Action: Commerce Line Item: Set the unit price to a specific amount: Parameter: Line item: [commerce_line_item], Value: [commerce-line-item:commerce-product:field-adminprice:amount]
The reason you have to use the commerce_line_item-supplied action instead of just using set-data-value is that the line item actually manages and stores all components involved in the calculation of the price, and this is just one of them.
The recipe listed above worked like a charm. Problem is, when I reached the checkout screen, my "Order Total" did not comput correctly. The order total was correct in the shopping cart block, however, at checkout my order total was incorrect. Any ideas?
If you can give more detail it will be easier to help you. Like... What does "incorrect" mean? Screenshots of your cart and checkout and rules would help.
Well I tried it myself and I didn't get any errors setting up the Conditions or Actions in the Rules. But, my total is still pulling from the typical unit price and not the discounted admin price.
Took me a while to finally get how I have to declare in the Conditions what I want to pull for the Actions, just not sure what I'm doing wrong at this point.
goal:
trade - see retail and wholesale price
annoy. and auth. user see retail price.
use kickstart2.0
did not setup admin price , use std commerce_price which is a std field in product variation
use commerce_price_eur, as retail price, a std field after enabling mulitcurrency.
is this wrong?
then I make commerce_price hidden. Wrong again?
follow the receipe, except
Value: [commerce-line-item:commerce-product:field-commerce_price:amount]
Roles: shop (instead of admin, already admin/people/permissions/roles and add a new role: shop)
This worked perfectly... for one other price. I have a scenario that is a little more complex though. Sometimes a product is taken to different venues where I could have two to three different prices for the same product. Can any of you suggest how to best do that? Just add another price and another rule? Would that make sense?
If there is a logic to the price selection, then I guess you should be able to add that as a condition of the rule, adding prices to the product as before.
maybe i did not post my question at the right place, therefore did not get any feedback.
Let me try again.
Goal :
everyone see retail price (commerce_price)
user (shop) see both retail and trade price
with multicurrency enabled, I have 3 default price input field:
1. commerce_price (input trade price) , instead of creating a field as rfay suggested. Question 1 : Is it ok to use this default field?
2. commerce_price_eur (input retail price)
3. commerce_price_usd
Question 2: Do i have to "hidden" commerce_price (input trade price) in the content type, manage display?
Go to admin/people/permissions/roles and add a new role: shop
Then I did as rfay suggested
Create a product pricing rule:
When calculating the sell price of an order
Condition: Entity has field Parameter: Entity: [commerce-line-item], Field: commerce_product
Condition: Entity has field Parameter: Entity: [commerce-line-item:commerce-product Field: commerce_price
Condition: : User: [site:current-user], Roles: shop
Action: Commerce Line Item: Set the unit price to a specific amount: Parameter: Line item: [commerce_line_item], Value: [commerce-line-item:commerce-product:commerce_price:amount]
When login as shop , the commerce_price (trade price) did not show up?
Where did I do wrong?
Comments
Now I try: 1. Add to product
Now I try:
1. Add to product field 'price2' (of type 'price').
2. Make pricing rule:
event: Calculating the sell price of a product
condition: User has role(s)
action: ???
What action I must use for copying price from field 'field_price2'?
May be is some another way..
Recipe
OK, I just tried this out and it seems to be OK.
1. Add a field called adminprice to the product.
2. Create a product pricing rule:
When calculating the sell price of an order
Condition: Entity has field Parameter: Entity: [commerce-line-item], Field: commerce_product
Condition: Entity has field Parameter: Entity: [commerce-line-item:commerce-product Field: field_adminprice
Condition: : User: [site:current-user], Roles: administrator
Action: Set a data value: Parameter: Data: [commerce-line-item:commerce-unit-price:amount], Value: [commerce-line-item:commerce-product:field-adminprice:amount]Action: Commerce Line Item: Set the unit price to a specific amount: Parameter: Line item: [commerce_line_item], Value: [commerce-line-item:commerce-product:field-adminprice:amount]
The reason you have to use the commerce_line_item-supplied action instead of just using set-data-value is that the line item actually manages and stores all components involved in the calculation of the price, and this is just one of them.
It is work! Many thanks.
It is work! Many thanks.
Price at Checkout Incorrect
Randy,
The recipe listed above worked like a charm. Problem is, when I reached the checkout screen, my "Order Total" did not comput correctly. The order total was correct in the shopping cart block, however, at checkout my order total was incorrect. Any ideas?
Can you give more detail
If you can give more detail it will be easier to help you. Like... What does "incorrect" mean? Screenshots of your cart and checkout and rules would help.
Wrong total
I have problem with "Order total". It is still use the base price on /checkout page.
Rule export:
{ "rules_price_for_operator" : {
"LABEL" : "price_for_operator",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"IF" : [
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "5" : "5" } },
"operation" : "OR"
}
},
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
{ "entity_has_field" : {
"entity" : [ "commerce-line-item:commerce-product" ],
"field" : "field_priceoperator"
}
}
],
"DO" : [
{ "data_set" : {
"data" : [ "commerce-line-item:commerce-unit-price:amount" ],
"value" : [ "commerce-line-item:commerce-product:field-priceoperator:amount" ]
}
}
]
}
}
Hmm
Well I tried it myself and I didn't get any errors setting up the Conditions or Actions in the Rules. But, my total is still pulling from the typical unit price and not the discounted admin price.
Took me a while to finally get how I have to declare in the Conditions what I want to pull for the Actions, just not sure what I'm doing wrong at this point.
Any thoughts? Thanks.
I can recreate this problem
I see the problem too. I'll talk about it with Ryan.
Figured it out: Use Commerce Line Item's Set the Unit Price
Rather than use "set a data value", the correct way to do this is to use the Commerce Line Item specific actions.
I will edit the recipe above to show the correct technique.
It is work.
It is work. Thanks.
Worked beautifully! Thanks a
Worked beautifully! Thanks a lot Randy.
Worked!
Thanks Randy! Works like a charm!
Beautiful...
This is EXACTLY what I was looking for tonight. Thank you! Works perfectly.
Is there a way to
Is there a way to automatically apply a coupon to an order based on the user's role? I want to highlight their fantastic savings.
Need help fast.
Can not get this.
Is it the "product" I'll add a field, and how do I do this? Or is it my own content type that I made?
If the error message "Value": The data selector commerce-line item: commerce product: field-admin price: amount for the amount parameter is invalid.
Solutions
I found my solutions for this time.
not work, where wrong?
goal:
trade - see retail and wholesale price
annoy. and auth. user see retail price.
use kickstart2.0
did not setup admin price , use std commerce_price which is a std field in product variation
use commerce_price_eur, as retail price, a std field after enabling mulitcurrency.
is this wrong?
then I make commerce_price hidden. Wrong again?
follow the receipe, except
Value: [commerce-line-item:commerce-product:field-commerce_price:amount]
Roles: shop (instead of admin, already admin/people/permissions/roles and add a new role: shop)
when shop login. commerce_price is still hidden??
role base product price
I fully agree with this statement.
This is the only way to consider Drupal Commerce as a B2B tool.
Guy Fauquembergue.
More than two prices for a product
This worked perfectly... for one other price. I have a scenario that is a little more complex though. Sometimes a product is taken to different venues where I could have two to three different prices for the same product. Can any of you suggest how to best do that? Just add another price and another rule? Would that make sense?
If there is a logic to the
If there is a logic to the price selection, then I guess you should be able to add that as a condition of the rule, adding prices to the product as before.
no answer
maybe i did not post my question at the right place, therefore did not get any feedback.
Let me try again.
Goal :
everyone see retail price (commerce_price)
user (shop) see both retail and trade price
with multicurrency enabled, I have 3 default price input field:
1. commerce_price (input trade price) , instead of creating a field as rfay suggested. Question 1 : Is it ok to use this default field?
2. commerce_price_eur (input retail price)
3. commerce_price_usd
Question 2: Do i have to "hidden" commerce_price (input trade price) in the content type, manage display?
Go to admin/people/permissions/roles and add a new role: shop
Then I did as rfay suggested
Create a product pricing rule:
When calculating the sell price of an order
Condition: Entity has field Parameter: Entity: [commerce-line-item], Field: commerce_product
Condition: Entity has field Parameter: Entity: [commerce-line-item:commerce-product Field: commerce_price
Condition: : User: [site:current-user], Roles: shop
Action: Commerce Line Item: Set the unit price to a specific amount: Parameter: Line item: [commerce_line_item], Value: [commerce-line-item:commerce-product:commerce_price:amount]
When login as shop , the commerce_price (trade price) did not show up?
Where did I do wrong?