Categories
CMS Magento Mastering Development

magento 2 extension attribute value is coming null

I an creating a customer address attribute using this code <?php namespace Ansh\CustomAddressAttribute\Setup; use Magento\Customer\Model\Customer; use Magento\Customer\Setup\CustomerSetup; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class UpgradeData implements UpgradeDataInterface { private $customerSetupFactory; public function __construct(\Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory) { $this->customerSetupFactory = $customerSetupFactory; } public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context){ $setup->startSetup(); /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create([‘setup’ => […]

Categories
CMS Magento Mastering Development

Magento 2 split order based on product attribute

I’m developing Multivendor masrketplace mdoule. I need to split orders based on seller id’s which assigned to product. I tried using this free module. Link But this is not working with attributes. So I tried to split with sku. Where I modified the code like below. <?php namespace Magestat\SplitOrder\Plugin; use Magento\Quote\Model\QuoteManagement; use Magento\Framework\Exception\LocalizedException; use Magento\Quote\Api\CartRepositoryInterface; […]

Categories
CMS Magento Mastering Development

Magento 2 split order based on product attribute

I’m developing Multivendor masrketplace mdoule. I need to split orders based on seller id’s which assigned to product. I tried using this free module. Link But this is not working with attributes. So I tried to split with sku. Where I modified the code like below. <?php namespace Magestat\SplitOrder\Plugin; use Magento\Quote\Model\QuoteManagement; use Magento\Framework\Exception\LocalizedException; use Magento\Quote\Api\CartRepositoryInterface; […]

Categories
CMS Magento Mastering Development

Magento 2 split order based on product attribute

I’m developing Multivendor masrketplace mdoule. I need to split orders based on seller id’s which assigned to product. I tried using this free module. Link But this is not working with attributes. So I tried to split with sku. Where I modified the code like below. <?php namespace Magestat\SplitOrder\Plugin; use Magento\Quote\Model\QuoteManagement; use Magento\Framework\Exception\LocalizedException; use Magento\Quote\Api\CartRepositoryInterface; […]

Categories
CMS Magento Mastering Development

Checkout custom shipping address field – set as required

I have created a custom module that adds a text field in shipping address. It’s workin ok but I’d like to make it required. How can I do that? I tried adding ‘required-entry’ => true at validation parameter, in file Plugin/Checkout/LayoutProcessor.php but it didn’t work. Here are the module files: Mymodules/FieldCheckout/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, ‘Mymodules_FieldCheckout’, […]

Categories
CMS Development Magento

Can get shipping extension_attributes in observer Magento 2

Hi I want to save a shipping address attribute by observer sales_model_service_quote_submit_before Bellow My observer: public function execute(Observer $observer) { $quote = $observer->getEvent()->getQuote(); $fields = $this->fieldsManagement->getByQuoteId($quote->getId()); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $resource = $objectManager->get(‘Magento\Framework\App\ResourceConnection’); $customer_res = $objectManager->create(‘Magento\Customer\Api\AddressRepositoryInterface’); $customer = $customer_res->getById(101); $shippingAddress = $quote->getShippingAddress(); $shippingAddressExtensionAttributes = $shippingAddress->getExtensionAttributes(); if ($shippingAddressExtensionAttributes) { $customField = $shippingAddressExtensionAttributes->getDistance(); $customer->setCustomAttribute(‘distance’,$customField); }else{ $customer->setCustomAttribute(‘distance’,’not save’); } […]

Categories
CMS Development Magento

Magento 2 hide shipping methods based on product attribute & shipping address out of USA

I Would like to hide shipping methods and display a custom message on the checkout page & cart page based on product attribute flag & if the shipping address is outside of the USA. I used the below plugin but it triggers only logged-in users unable to verify with guest users. Could you please advise […]

Categories
CMS Development Magento

Magento 2 hide shipping methods based on product attribute & shipping address

I Would like to hide shipping methods and display a custom message on the checkout page & cart page based on product attribute flag & if the shipping address is outside of the USA. I used the below plugin but it triggers only logged-in users unable to verify with guest users. Could you please advise […]

Categories
CMS Development Magento

Magento 2 hide shipping methods based on product attribute

I Would like to hide shipping methods and display custom message on the checkout page & cart page based on product attribute flag & if the shipping address is outside of the USA. I used the below plugin but it triggers only logged-in users unable to verify with guest users. Could you please advise what […]

Categories
CMS Development Magento

How to display a message when unset a shipping method in magento 2.3 using aroundEstimateByExtendedAddress plugin?

Want to display a message after certain conditions, how to achieve that? class ShipmentEstimationPlugin { public function __construct( \Magento\Customer\Model\Session $customerSession ) { $this->customerSession = $customerSession; } public function aroundEstimateByExtendedAddress( ShipmentEstimationInterface $subject, \Closure $proceed, $cartId, \Magento\Quote\Api\Data\AddressInterface $address ) { $writer = new \Zend\Log\Writer\Stream(BP . ‘/var/log/testshipping.log’); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get(‘\Magento\Checkout\Model\Cart’); […]