Needs work
Project:
Commerce Costs
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2018 at 22:57 UTC
Updated:
16 May 2019 at 23:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
travis-bradbury commentedWork in progress. This adds a cost trait. It's using the name "cost" instead of "field_cost". I'll need to change existing field_cost fields to cost. We probably either want this in the base module since order items must have a field even if products resolve theirs another way, but maybe order items could have the trait in the main module and products in the submodule?
Comment #3
travis-bradbury commentedWork in progress. Working on moving the trait to commerce_cost itself and setting the trait on types that already have field_cost, then moving the data over.
Also needs to change anywhere `field_cost` is used to `cost` but that should be the easy part.
Comment #4
travis-bradbury commentedComment #5
travis-bradbury commentedNot a lot to show for the next patch but it represents some progress that's pretty cool.
I threw out most of the update hook because I saw how to use the entity trait manager to load the cost trait and install it rather than trying to install the field manually.
Though untested, this should add the trait to any product variation or order item type that has field_cost. It still needs to migrate data and I have to decide what to do about the old field_cost (probably leave it for manual deletion). And then things have to start using cost instead of field_cost.
Comment #6
travis-bradbury commentedThis should create the traits and migrate the data to the new field. Needs testing on sample data.
Comment #7
travis-bradbury commented$entity_trait_manager->installTrait($trait, 'commerce_product_variation', $type);should use $entity_type, not hard-coded commerce_product_variation.Comment #8
travis-bradbury commented#2971216-2: Move PriceWithCostWidget to the main module: shouldn't this trait be in the fields submodule so an a field-less implementation of costs you wouldn't have the trait field?