我想在结帐的订单处理过程中添加日期选择器。订单的自定义字段应该在哪一步更新?订单或其他实体的自定义字段更新是如何完成的? 我想添加官方文档中显示的字段。
$this->customFieldSetRepository->create([
[
'name' => 'swag_example',
'customFields' => [
['name' => 'swag_example_size', 'type' => CustomFieldTypes::INT],
['name' => 'swag_example_color', 'type' => CustomFieldTypes::TEXT]
]
]
], $context);
最佳答案
在订购过程中您到底想在哪里添加这些数据?
一个示例是从确认到完成 -> 购物车转换为订单。 您只需为此创建一个订阅者:
<?php
class OrderProcessSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
CartConvertedEvent::class => 'addCustomFieldsToConvertedCart',
];
}
public function addCustomFieldsToConvertedCart(CartConvertedEvent $event)
{
$convertedCart['customFields']['my_custom_field'] = 'test';
$event->setConvertedCart($convertedCart);
}
}
?>
关于symfony - 如何在订单处理过程中更新 Shopware 6 中的订单自定义字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66439604/