2

in project i have two different custom shipping method one for 8 to 15 days delivery and 2 to 4 days delivery. i have create coupon code for free shipping but i want to allow free shipping coupon code to only 8 to 15 days shipping method. please help.

1

You can change code in your carrier model file collectRates function check coupon code is applied or not from calling quote object and set custom price if your 8 to 15 days delivery method available and set 0 price for free shipping .

you can get a coupon code from quote object from here

$quote  = $this->session->getQuote();

$address = $quote->getShippingAddress();

$shippingaddress    = $quote->getShippingAddress()->getData();

$coupon     = $quote->getCouponCode();

Before apply this code you have to declare session in construct method like this

protected $session;

public function __construct(

\Magento\Checkout\Model\Session $session, ) {   

$this->session = $session;

}

after then you get quote data from session in magento 2.

0
2

Magento Provide Shipping Method condition it self,

You need to select that shipping method into condition section, For which you want to generate coupen code.

See the screen-sort. enter image description here

4
  • this will not work for me bcz i am using table rate shipping method and i have create module for custom table rate shipping method – Navin Bhudiya Dec 28 '16 at 12:58
  • you can change your custom module development, So that method avilable into this list, so you can select that. – Dhiren Vasoya Dec 28 '16 at 12:59
  • ok i am trying that one – Navin Bhudiya Dec 28 '16 at 13:00
  • Above answer help please accept, so other can get help in community. – Dhiren Vasoya Dec 28 '16 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.