Replies: 2 comments 3 replies
-
This would be against existing conventions. For example, So I’d vote against this change. |
Beta Was this translation helpful? Give feedback.
-
This is certainly a good feature request and the ability to have proper control over the order of line items is definitely something we will look into in the future. We will keep this FR open. In the meantime, you are able to tweak the Here is an example of setting every new insert with the date use craft\commerce\records\LineItem;
use yii\base\ModelEvent;
// ...
Event::on(
LineItem::class,
LineItem::EVENT_BEFORE_INSERT,
function(ModelEvent $event) {
$event->sender->dateCreated = Db::prepareDateForDb(new \DateTime('1970-01-01 01:59:59'));
}
); Hope this helps in the short term, thanks! |
Beta Was this translation helpful? Give feedback.
-
I need to sort the items in a cart by certain criteria.
I can do that in an adjuster, in which case the response of
/actions/commerce/cart/update-cart
has to correct order (because it returns the in-memoryOrder
object). however, I also need to persist the custom order, so that the backend, invoice pdf, etc. also use the correct order!setting
$lineItem->dateCreated = /* ... */;
does not work because it never actually gets stored in the db again. — the only way to currently do it is to re-implement (and maintain) a slightly different version of saveLineItem() 😞PR: #3130
Beta Was this translation helpful? Give feedback.
All reactions