You can't change the unit price of a line item in the order edit screen although it's a form element indicating that it is changeable.

How to reproduce:

Add a product to your cart
Proceed through the checkout
Go to admin/commerce/orders en click 'edit' next to your order
Change the 'unit price' of the line item representing the product in your order
Hit the 'Save' button
Notice how the line item 'unit price' is changed back to the original value

Comments

netsensei’s picture

Title: Impossible to change the unit price of a line item in the order edit screen » Decouple the unit price from a line item and a product on the order edit screen

Actually, come to think of it: the problem is that the unit price displayed on the line item manager is actually the price referenced from the product. I noticed that line items themselves don't store the price of a product.

Suppose 10 people order a product during the first week a product is out. After a week, the price on the product is changed by 25%. This will cause the line item display to show totally different pricing for those first 10 orders since the price of the line items is calculated dynamically.

The only reference people have of the original pricing on the order is their confirmation e-mail. If there's a dispute, there is no way for the store to retrieve the original order pricing.

Another problem: if an order is checked out, and payment gets delayed by 24h. Changes to the price in the order might corrupt the payment process as some payment gateways do a re-check after 24h and use the calculated amount as a verification parameter.

So, creating a separate field or even a entity property for line items which hold the unit price of a product at the time it was added to the cart would be the way to go me thinks.

pcambra’s picture

Title: Decouple the unit price from a line item and a product on the order edit screen » Line item unit price and currency aren't modifiable when the order is in cart status
Component: Line item » Cart
Status: Active » Needs review

The price referenced in the line item of an order is separated from the original product price, line item entity has several files, one of them is the unit price of the products added to that line item.
The thing is that when you load an order which status is cart (as today "Shipping cart", "Checkout: Checkout", "Checkout:Review" have this status), the prices are recalculated in order to keep consistence with the product prices, you may have added a product last week to your cart, but the price of that product has raised, or there is a discount now that wasn't there last week...
You can change unit price and currency of orders in more advanced status, like Pending, Payment received and so on.
This commit adds a form alter to the line item edition that disables editing for unit price and currency code to avoid admins to get confused trying to edit some options that aren't really modifiable.

Pull request:
https://github.com/pcambra/drupalcommerce/commit/a20af1990a3853b5f1308c1...

rszrama’s picture

Status: Needs review » Fixed

I've committed this fix for now. It doesn't mean we can't revisit this decision in the future, but I believe it will be a minority case where administrators will actually need to build shopping cart orders with custom pricing for a customer to checkout. I'm sure there will be use cases, but for now those will require either a separately priced product, a pricing rule, or perhaps a different type of line item. They can always modify the price after checkout is completed but prior to capturing the payment as well.

netsensei’s picture

Okay. I see. I was trying to change the order while it was still in the shopping cart. Changing the status to 'completed' allows me to change the unit price.

So, I agree with pcambra's patch.

Status: Fixed » Closed (fixed)
Issue tags: -dcsprint5

Automatically closed -- issue fixed for 2 weeks with no activity.

manuelgc’s picture

Issue summary: View changes

Hi,

I have a use case that admin require edit unit price in checkout_checkout status. When user (not same admin user) visit the order, the price change to product unit price.

I need to mantain custom price that admin set on line item order. This could be a use case similar to exposed here.

In other words, I need set custom price to line items orders in checkout_* status (not payment status).