Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoreBundle] fix quote notification sending 3.x #1869

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use CoreShop\Component\Core\Model\CustomerInterface;
use CoreShop\Component\Order\Model\OrderInterface;
use CoreShop\Component\Order\OrderSaleStates;
use Symfony\Component\Workflow\Event\Event;

final class OrderWorkflowListener extends AbstractNotificationRuleListener
Expand All @@ -28,13 +29,17 @@ public function applyOrderWorkflowRule(Event $event): void
return;
}

if (!in_array($order->getSaleState(), [OrderSaleStates::STATE_QUOTE, OrderSaleStates::STATE_ORDER], true)) {
return;
}

$customer = $order->getCustomer();

if (!$customer instanceof CustomerInterface) {
return;
}

$this->rulesProcessor->applyRules('order', $order, [
$this->rulesProcessor->applyRules($order->getSaleState(), $order, [
'workflow' => $event->getWorkflowName(),
'fromState' => $event->getMarking()->getPlaces(),
'toState' => $event->getTransition()->getTos(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@

declare(strict_types=1);

namespace CoreShop\Bundle\CoreBundle\EventListener\NotificationRules;
namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

use CoreShop\Component\Core\Model\OrderInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Webmozart\Assert\Assert;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

final class QuoteListener extends AbstractNotificationRuleListener
final class OrderSaleStateConfigurationType extends AbstractType
{
public function applyRule(GenericEvent $event): void
public function buildForm(FormBuilderInterface $builder, array $options): void
{
Assert::isInstanceOf($event->getSubject(), OrderInterface::class);

$this->rulesProcessor->applyRules('quote', $event->getSubject());
$builder
->add('saleState', TextType::class, [
]);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ services:
tags:
- { name: coreshop.notification_rule.condition, type: orderState, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderStateConfigurationType }

coreshop.notification_rule.condition.order.order_sale_state:
class: CoreShop\Component\Core\Notification\Rule\Condition\SimpleStateChecker
arguments:
- 'CoreShop\Component\Order\Model\OrderInterface'
- 'saleState'
- 'saleState'
tags:
- { name: coreshop.notification_rule.condition, type: saleState, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderSaleStateConfigurationType }
- { name: coreshop.notification_rule.condition, type: saleState, notification-type: quote, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderSaleStateConfigurationType }

coreshop.notification_rule.condition.order.order_transition:
class: CoreShop\Component\Core\Notification\Rule\Condition\StateTransitionChecker
arguments:
Expand Down Expand Up @@ -206,18 +216,15 @@ services:
- '@CoreShop\Component\Notification\Processor\RulesProcessorInterface'
- '@CoreShop\Component\Core\Context\ShopperContextInterface'

CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\QuoteListener:
parent: CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\AbstractNotificationRuleListener
tags:
- { name: kernel.event_listener, event: coreshop.quote.post_transform, method: applyRule }

CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\OrderWorkflowListener:
parent: CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\AbstractNotificationRuleListener
tags:
- { name: kernel.event_listener, event: workflow.coreshop_order.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_invoice.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_shipment.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_payment.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_quote.completed, method: applyOrderWorkflowRule }
- { name: kernel.event_listener, event: workflow.coreshop_order_sales_type.completed, method: applyOrderWorkflowRule }

CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\OrderCommentsListener:
parent: CoreShop\Bundle\CoreBundle\EventListener\NotificationRules\AbstractNotificationRuleListener
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*
*/

pimcore.registerNS('coreshop.notification.rule.conditions.saleState');

coreshop.notification.rule.conditions.saleState = Class.create(coreshop.rules.conditions.abstract, {
type: 'saleState',

getForm: function () {
this.form = Ext.create('Ext.form.FieldSet', {
items: [
{
xtype: 'combo',
fieldLabel: t('coreshop_transition_direction_state'),
name: 'saleState',
value: this.data ? this.data.saleState : [],
width: 250,
store: pimcore.globalmanager.get('coreshop_states_order_sales_type'),
triggerAction: 'all',
typeAhead: false,
editable: false,
forceSelection: true,
queryMode: 'local',
displayField: 'label',
valueField: 'state'
}
]
});

return this.form;
}
});