- 🇩🇪Germany 4kant
two questions that likely/probably fit into this issue:
- In checkout the customer can select the carrier. If that´s intentional: that should be hidden in my case --> I have only UPS so far
- Maybe at least a "default" carrier could be set automatically
Anyway - thanks for the module!
In checkout the customer can select the carrier. If that´s intentional: that should be hidden in my case --> I have only UPS so far
The carrier field can be hidden in the shipment type field display.
Maybe at least a "default" carrier could be set automatically
The default carrier could be set in the shipping method, and then we would need to set the shipping carrier on the shipment:
$shipment->set('shipping_carrier', $shipping_carrier);
Again, I would be glad to review a patch.
Adding this to the module file gets our field on the shipping method:
if ($entity_type->id() === 'commerce_shipping_method') { $fields['shipping_carrier'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Shipping carrier')) ->setCardinality(1) ->setRequired(FALSE) ->setDescription(t('The shipping carrier')) ->setSetting('target_type', 'commerce_shipping_carrier') ->setDisplayOptions('form', [ 'type' => 'options_select', 'weight' => 0, ]) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); }
Plugin would probably be better, but I don't really have time to figure out how to do that. :)
- Status changed to Needs review
over 1 year ago 12:15am 17 March 2023 Here is a sloppy patch to test the idea. You will need to run
drush entup
with devel_entity_updates, or something like that to get the field.- Status changed to Active
over 1 year ago 2:29am 17 March 2023 Not really sure I want to hard code this. Carrier module already provides the field, and shipping methods are fieldable, but there is no UI.
See https://www.drupal.org/project/commerce_shipping/issues/3276238 →
Ideally, users could add the field to the shipping method, and implement their own logic in an event subscriber.
- Status changed to Needs review
over 1 year ago 2:15pm 17 March 2023 On second thought, adding the field to the shipping method field data seems harmless, as that will be removed if the carrier module is uninstalled. This would at least make it easier for people who want to add subscribers.
Here is a little cleaner patch. Might rethink the name of the subscriber that ships with the module.