PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

[FIXED] How to add Custom option value on coupon rules Magneto 2

 August 23, 2022     magento2, php     No comments   

Issue

How to add Custom option value on coupon rules Magneto 2. I have a product which have some custom option like size, color etc. with different value, I want give discount on basic of size = 7'. I don't want use sku custom option.. Let me know how I fix it. https://github.com/Turiknox/magento2-custom-total Moulde I use for Discount but i have face a problem. one Data I can't get cart information

    $obj = $bootstrap->getObjectManager();

// Set the state (not sure if this is neccessary)
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');

// Getting the object managers dependencies 
$quote = $obj->get('Magento\Checkout\Model\Session')->getQuote();
$helper = $obj->get('\Magento\Checkout\Helper\Cart');

// Get quote and cart items collection
$quote = $helper->getQuote();
$quoteitems = $quote->getAllItems();

$coupon_code = 'Test23';
// Get cart contents
$cart= $helper->getCart();  
foreach ($quoteitems as $item)
{

}

It goes to the infinity loop.


Solution

This one Run fast that's why here we can't load quote total, For Discount given you must set session core cookies which allow giving discount...



Answered By - AL-MAHBUB KHAN
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing