Skip to content

shipping-methods

Auto Added by WPeMatico

Magento 2: Create order programmatically using carrier containing underscore (PostNL)

I am unable to create an order programmatically with the carrier PostNL. The carrier code is “tig_postnl” and the method “regular”. Normally I set the shipping address simply using: $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setCollectShippingRates(true) ->collectShippingRates() ->setShippingMethod(‘freeshipping_freeshipping’); (for full code please see… Read More »Magento 2: Create order programmatically using carrier containing underscore (PostNL)

what is the use of shipping setprice and shipping setcost

What is the use of setprice and setcost in shipping carrier? public function collectRates(RateRequest $request) { if (!$this->getConfigFlag(‘active’)) { return false; } /** @var MagentoShippingModelRateResult $result */ $result = $this->rateResultFactory->create(); /** @var MagentoQuoteModelQuoteAddressRateResultMethod $method */ $method = $this->rateMethodFactory->create(); $method->setCarrier($this->_code); $method->setCarrierTitle($this->getConfigData(‘title’));… Read More »what is the use of shipping setprice and shipping setcost

how to validate custom condition rule based on product attribute?

I am using plugin for the same pusrpose. <type name=”MagentoShippingModelShipping”> <plugin name=”hide_shipping_method_based_on_product_attribute” type=”VendorShippingRestrictionsPluginMagentoShippingModelProductAttributeBasedShipping” disabled=”false” /> </type> And public function aroundCollectCarrierRates( MagentoShippingModelShipping $subject, Closure $proceed, $carrierCode, $request ) { $allItems = $request->getAllItems(); $storeId = $this->storeManager->getStore()->getId(); $ruleCollection = $this->collectionFactory->create() ->addFieldToSelect(‘*’) ->addFieldToFilter(‘status’, [‘eq’… Read More »how to validate custom condition rule based on product attribute?