Shipment + Approval Process Feature Integration
  • Updated on 12 May 2020
  • 2 minutes to read
  • Print
  • Share
  • Dark
    Light

Shipment + Approval Process Feature Integration

  • Print
  • Share
  • Dark
    Light

Install Feature Core

Prerequisites

To start feature integration, overview and install the necessary features:

Name Version
Shipment master
Approval Process master

1) Install the Required Modules Using Composer

Run the following command(s) to install the required modules:

composer require spryker/quote-approval-shipment-connector:"^1.0.0" --update-with-dependencies
Verification

Make sure that the following modules were installed:

Module Expected Directory
QuoteApprovalShipmentConnector vendor/spryker/quote-approval-shipment-connector

2) Set up Configuration

Add the following configuration to your project:

src/Pyz/Shared/QuoteApproval/QuoteApprovalConfig.php

<?php
 
namespace Pyz\Shared\QuoteApproval;
 
use Generated\Shared\Transfer\QuoteTransfer;
use Spryker\Shared\QuoteApproval\QuoteApprovalConfig as SprykerQuoteApprovalConfig;
 
class QuoteApprovalConfig extends SprykerQuoteApprovalConfig
{
    /**
     * @return bool
     */
    public function isShipmentPriceIncludedInQuoteApprovalPermissionCheck(): bool
    {
        return true;
    }
}
Verification

Make sure that shipment is calculated in the sum of the quote for a buyer sending the approval request on a single shipment case.

3) Set up Behavior

Set up Shipment Cost Behavior

Register the following plugins:

Plugin Specification Prerequisites Namespace
ShipmentApplicableForQuoteApprovalCheckPlugin Checks if quote has all parameters required for shipment calculation. None Spryker\Client\QuoteApprovalShipmentConnector\Plugin\QuoteApproval
QuoteApprovalShipmentQuoteFieldsAllowedForSavingProviderPlugin Gets the required shipment quote fields from the configuration if approval request is not canceled on a single shipment case. None Spryker\Zed\QuoteApprovalShipmentConnector\Communication\Plugin\Quote

src/Pyz/Client/QuoteApproval/QuoteApprovalDependencyProvider.php

<?php
 
namespace Pyz\Client\QuoteApproval;
 
use Spryker\Client\QuoteApproval\QuoteApprovalDependencyProvider as SprykerQuoteApprovalDependencyProvider;
use Spryker\Client\QuoteApprovalShipmentConnector\Plugin\QuoteApproval\ShipmentApplicableForQuoteApprovalCheckPlugin;
 
class QuoteApprovalDependencyProvider extends SprykerQuoteApprovalDependencyProvider
{
    /**
     * @return \Spryker\Client\QuoteApprovalExtension\Dependency\Plugin\QuoteApplicableForApprovalCheckPluginInterface[]
     */
    protected function getQuoteApplicableForApprovalCheckPlugins(): array
    {
        return [
            new ShipmentApplicableForQuoteApprovalCheckPlugin(),
        ];
    }
}

src/Pyz/Zed/Quote/QuoteDependencyProvider.php

<?php
 
namespace Pyz\Zed\Quote;
 
use Spryker\Zed\Quote\QuoteDependencyProvider as SprykerQuoteDependencyProvider;
use Spryker\Zed\QuoteApprovalShipmentConnector\Communication\Plugin\Quote\QuoteApprovalShipmentQuoteFieldsAllowedForSavingProviderPlugin;
 
class QuoteDependencyProvider extends SprykerQuoteDependencyProvider
{
    /**
     * @return \Spryker\Zed\QuoteExtension\Dependency\Plugin\QuoteFieldsAllowedForSavingProviderPluginInterface[]
     */
    protected function getQuoteFieldsAllowedForSavingProviderPlugins(): array
    {
        return [
            new QuoteApprovalShipmentQuoteFieldsAllowedForSavingProviderPlugin(),
        ];
    }
}
Verification

Make sure that a quote without shipment cannot be sent to the approval request.

Make sure that shipment is saved with the quote in the spy_quote table after sending an approval request.

Install Feature Frontend

Prerequisites

To start feature integration, overview and install the necessary features:

Name Version
CheckoutPage master

1) Set up Behavior

Set up Shipment Cost Behavior

Register the following plugins:

Plugin Specification Prerequisites Namespace
QuoteApprovalCheckerCheckoutShipmentStepEnterPreCheckPlugin Checks if the quote approval status is approved or waiting on the shipment step of the checkout. None SprykerShop\Yves\QuoteApprovalWidget\Plugin\CheckoutPage

src/Pyz/Yves/CheckoutPage/CheckoutPageDependencyProvider.php

<?php
  
namespace Pyz\Yves\CheckoutPage;
 
use SprykerShop\Yves\CheckoutPage\CheckoutPageDependencyProvider as SprykerShopCheckoutPageDependencyProvider;
use SprykerShop\Yves\QuoteApprovalWidget\Plugin\CheckoutPage\QuoteApprovalCheckerCheckoutShipmentStepEnterPreCheckPlugin;
 
/**
 * @method \Pyz\Yves\CheckoutPage\CheckoutPageConfig getConfig()
 */
class CheckoutPageDependencyProvider extends SprykerShopCheckoutPageDependencyProvider
{
    /**
     * @return \SprykerShop\Yves\CheckoutPageExtension\Dependency\Plugin\CheckoutShipmentStepEnterPreCheckPluginInterface[]
     */
    protected function getCheckoutShipmentStepEnterPreCheckPlugins(): array
    {
        return [
            new QuoteApprovalCheckerCheckoutShipmentStepEnterPreCheckPlugin(),
        ];
    }
}
Verification

Check that the customer with the sent approval request cannot open the shipment step on the cart page.

Was this article helpful?