Discussions

How can I give the seller one more chance to alter the total price of an order?

Hi,

I am currently working on a e-commerce website, and the basic workflow is as follows,

1) shopper adds products into the shopping cart;
2) shopper submit the order without payment;
3) seller reviews the orders submitted by shoppers, and is able to modify the total price of the order;
4) seller releases the orders back to shoppers, which might have been modified;
5) shopper pay for the order.

Obviously, steps 2~4 are different from the regular process, and I am wondering how can I accomplish these steps.

Any suggestions how/where to start? Any existing modules that can be used for this purpose?

Thanks in advance for help.

Posted: Aug 26, 2014

Comments

joshmiller Josh Miller on August 27, 2014

Since we're talking about Drupal Commerce, the answer is always "Yes, it can do that."

:D

So in your case, you could use the normal checkout workflow, with a few tweaks:

  • You would need a custom boolean (single on/off) checkbox field on the Order entity called "Lock Prices"
    • Go here: admin/commerce/config/order/fields
    • Add a boolean field called "Lock Prices"
    • Move the order of the new field to above the line items field and save the new order
  • Also a custom price field on your line items called "Locked Price"
    • Go here: admin/commerce/config/line-items/product/fields
    • Add a price field called "Locked Price"
  • Create a view block that lets you edit the line items fields
    • Download and enable the editablefields module
    • Create a View Block of Line Items: admin/structure/views/add (choose line item entity, type product)
      • Add the "unit price" field of the line item
      • Add the "price locked" field and set the formatter to "editable"
      • Add a reference to the product
      • Add the product title and SKU fields
      • Add a "Commerce Line Item: Order ID" contextual filter
        • Provide default value: Raw value from URL
        • Path component: 4
        • check the "Use path alias" (not sure this is required?)
        • Check "Specify validation criteria" and set it to numeric and to display "no results" if it doesn't validate
      • Place the block on the admin page "content" above the normal content and set to only appear on the path: admin/commerce/orders/*/edit

Now, you will need one pricing rule:

Event: Calculating the sell price of a product: admin/commerce/config/product-pricing/rules/add

Condition: "Entity has field" Parameter: Entity: [commerce-line-item:order], Field: field_lock_prices

Condition: "Entity has field" Parameter: Entity: [commerce-line-item], Field: field_locked_price

Condition: "NOT Data value is empty" Data to check: [commerce-line-item:field-locked-price:amount]

Condition: "Data comparison" Data to compare: [commerce-line-item:order:field-lock-prices], Data value: Price Locked

Action: "Set the unit price to a specific amount" Parameter: Line item: [commerce_line_item], Amount: [commerce-line-item:field-locked-price:amount]

And you could (optionally) set up your payment gateway to only show up if the order has "Price Locked" checked. And for a "No Payment" method to only show up for non-locked orders (see the 1.x branch of the "No Payment" module).

Checkout Process:

  • User adds a product to cart
  • User checks out and selects a "free" payment gateway that's modified to be called "Submit for review"
  • Store owner edits the order to be price locked (checkbox)
  • Store owner edits the line item price-locked values that need to be tweaked.
  • Store owner sets the order back to "checkout:checkout"
  • Store owner sends email (or you could create a rule that sends an email) with a link to re-checkout with a url like this: checkout/[order_id]

Note: I was able to get this up and running on a Kickstart 1 site in about 5 minutes. Took much longer to document the process.