1

I'm using Drupal 7 Commerce and Commerce discount, amongst many others.

So the use case is this. We often get enquiries for bulk orders containing many products. We want our customer to go to the website and add what they want into their cart. As admin I want to open that unpaid cart, edit product prices and apply a Fixed Price Discount. Then when the customer refreshes their cart they will see our amendments and continue with payment. Is this possible? Am I missing something obvious?

At present I can edit a order that is in the cart but when the customer refreshes their cart the order is reverted back to prior my changes. I can't edit product prices at all whilst the order isn't completed. Once in Completed status, I can tweak product prices and add the discount.

To get the Fixed price discount feature to work I had to switch from the Line Item Manager widget over to Multiple Inline Entity References. For the line items field on orders that is. Before that I couldn't use the Fixed price discount feature at all.

Any help would be greatly appreciated. I must be performing the wrong searches or something.

2 Answers 2

0

There aren't many good solutions here, because you're hitting up against the limitations of the pricing system. You have two basic options: custom line item fields that contain special pricing paired with a pricing rule that overrides the default product price or some combination of discounts that adjust product prices solely for that user. The former may be a challenge, because I can't remember if we ever fully got Inline Entity Form to manage line items, and the latter would be a pain for orders with a lot of different products.

The Commerce Price List module was ultimately developed to handle situations like this, where price lists can be assigned on a per user / quantity basis. It appears the same feature set works in D7 as in D8, but it would give the customer access to that pricing on any order while the price list was active, not just a single one. If that's no problem, then that's probably your solution.

13
  • Thanks so much for your reply. I'm not too familiar with the pricing system side of commerce. I've only just got back to this task. I've chosen to go option 1 as things will vary per order. I've created the product line item field. Added a pricing rule however I can't get it to take effect. It's as follows: Event: calculating sell price. Condition: line item has the new discount price field & New field is not empty. Tried these actions: Set the unit price to a specific amount & Set a data value. No cigar though. Don't suppose you have any pointers?
    – gMaximus
    Jan 27, 2020 at 23:25
  • Set the unit price to that specific value should've worked imo. May need to ensure it's not being undone by some other rule firing after it? Jan 28, 2020 at 21:06
  • I thought it should have worked too. Sounds like a great idea and exactly the end result I needed. I'll check out the rules. I found this little module for sending a customer a link to complete checkout: github.com/sjsam/Drupal-MOPL. Just need to beat this into submission. We deal with customers via email and on Instagram. That's our motivation.
    – gMaximus
    Jan 29, 2020 at 2:58
  • 1
    The button only shows depending on the order status. Up until "Checkout: Payment" it is unavailable. That's why I couldn't find it. I was trying to add products and discounts, then let them check themselves out. That one snagged me for ages.
    – gMaximus
    Feb 4, 2020 at 0:27
  • 1
    It's all good. I know the feeling of trying to remember part of a system you haven't touched for a while. I wouldn't have done it so quickly if it hadn't been for you pointing me in the right direction with the additional field. Really appreciated...
    – gMaximus
    Feb 4, 2020 at 22:26
0

There was a few steps to this

1) Create a custom field on your product line items. Use a "price" field type. I called it "Discount unit price".
2) On your order entity line item field widget, you'll need the "Multiple Inline Entity References." This allows you to edit your custom field.
3) Create a pricing rule
   Event: Calculating the sell price of a product
   Conditions: 1) "Entity has field" and select our new field. 2) "Data value is empty" with the negate box checked. In other words we're interested if the field is not empty.
   Action: "Set the unit price to a specific amount". Enter the token for your new field. I used "amount" not "amount-decimal."
4) Create a 2nd rule to re-apply pricing rules when admins create or update a order
   Event: "After saving a new commerce order", "After updating an existing commerce order"
   Conditions: "User has roles". Select your admin roles.
   Action: "Execute custom PHP code" (you need "php filter" module enabled). Enter this "commerce_cart_order_refresh([commerce-order:order-id]);"
5) In order to send the customer a payment link with the discounted prices, install this small module: https://github.com/sjsam/Drupal-MOPL. When you download the zip folder, you'll want to change the folder name to "mopl".

In order to use this:
1) Create a new order or update a existing order.
2) Set your discounted prices in your new field.
3) Set the status to "Checkout: checkout".

The customer will now get a link to click in order to complete the checkout.

If they have populated their cart first. Edit it accordingly and save the order. When they refresh the page their cart prices will get updated.

In the question I also wanted to add a fixed price discount from the discount module. I couldn't work out how to have the "Fixed price discount" applied when the customer completes checkout. So I created a product called Discount and set the price to zero. I then add that product to the cart and set the discounted unit price to the discount I want ie -300.

At this point the customer could go back to the Shopping cart page and update the qty for the discount product. So I added a filter to exclude the "discount" product.

That's it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.