FosterCommerce / shipstation-connect

A plugin for Craft Commerce 2 that integrates with ShipStation.
https://plugins.craftcms.com/shipstationconnect
Other
7 stars 10 forks source link

Add ability to override fields, such as title or quantity #22

Closed aladrach closed 2 years ago

aladrach commented 3 years ago

We have a particular client that would like to be able to modify the title and quantity fields that are being sent to ShipStation, as we have custom business logic that modify those values. If that is possible, that would be amazing!

Thank you!

johnnynotsolucky commented 3 years ago

@aladrach currently there's no way to do that without updating the code. However, it is possible to set the CustomeField1, CustomField2 and CustomField3 values: https://github.com/FosterCommerce/shipstation-connect#custom-fields.

Event::on(
    Xml::class,
    Xml::ORDER_FIELD_EVENT,
    function (OrderFieldEvent $e) {
        $fieldName = $e->field;

        if ($fieldName === OrderFieldEvent::FIELD_CUSTOM_FIELD_1) {
            $e->value = "My Custom Field Value";
            $e->cdata = true;
        }
    }
);

Would these custom fields serve your purpose?

I'd actually prefer to remove that event completely and replace it with a single ShipStation Order type which can be completely customized. But that requires us to overhaul a substantial portion of the current logic.