Skip to content
Snippets Groups Projects
Select Git revision
  • 7dce00d6e00a226d65aef2790855bad9c5a6ef75
  • dev default protected
  • prod protected
  • 1.0.58
  • 1.0.57
  • 1.0.52
  • 1.0.56
  • 1.0.51
  • 1.0.50
  • 1.0.33
  • 1.0.32
  • 1.0.31
  • 1.0.30
  • 1.0.29
  • 1.0.28
  • 1.0.27
  • 1.0.26
  • 1.0.25
  • 1.0.24
  • 1.0.23
  • 1.0.22
  • 1.0.21
  • 1.0.20
23 results

ShippingInformationManagement.php

Blame
  • ShippingInformationManagement.php 1014 B
    <?php
    
    namespace bobgo\CustomShipping\Plugin;
    
    use Magento\Quote\Api\CartRepositoryInterface;
    
    use Magento\Checkout\Api\Data\ShippingInformationInterface;
    
    /**
     * Class ShippingInformationManagement
     * @package bobgo\CustomShipping\Plugin
     * This class is supposed to copy the suburb attribute from the quote to the order object.
     */
    class ShippingInformationManagement
    {
        public CartRepositoryInterface $cartRepository;
    
        public function __construct(
            CartRepositoryInterface $cartRepository
        )
        {
            $this->cartRepository = $cartRepository;
        }
    
        public function beforeSaveAddressInformation($subject, $cartId, ShippingInformationInterface $addressInformation): array
        {
            $quote = $this->cartRepository->getActive($cartId);
            $deliveryNote = $addressInformation->getShippingAddress()->getExtensionAttributes()->getSuburb();
            $quote->setSuburb($deliveryNote);
            $this->cartRepository->save($quote);
            return [$cartId, $addressInformation];
        }
    
    }