How to apply Coupon on the Specific Products in Magento 2?Discount coupon is not working for minimum subtotalMagento model extension experiment, return: “class does not exist”Is the salesrule_coupon “expiration_date” field used for anything?Doesn't apply coupon on the already discount productsMagento 2.1 Create a filter in the product grid by new attributeHow to apply coupon code if specific products are available on the cart?Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.2.5 Mysql add a coupon cart rule to customers accountApply discount on specific product using coupon Magento2Set Coupen for specific Products. Magento 2
How can I track script which gives me "command not found" right after the login?
Are ETF trackers fundamentally better than individual stocks?
What do Xenomorphs eat in the Alien series?
What should tie a collection of short-stories together?
How to read the value of this capacitor?
How to explain that I do not want to visit a country due to personal safety concern?
What is the domain in a tikz parametric plot?
In a future war, an old lady is trying to raise a boy but one of the weapons has made everyone deaf
Do I need life insurance if I can cover my own funeral costs?
Existence of subset with given Hausdorff dimension
Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?
If curse and magic is two sides of the same coin, why the former is forbidden?
Instead of Universal Basic Income, why not Universal Basic NEEDS?
Why one should not leave fingerprints on bulbs and plugs?
Do I need to be arrogant to get ahead?
Why do passenger jet manufacturers design their planes with stall prevention systems?
Brexit - No Deal Rejection
My adviser wants to be the first author
Life insurance that covers only simultaneous/dual deaths
How to change two letters closest to a string and one letter immediately after a string using notepad++
Unexpected result from ArcLength
How to write cleanly even if my character uses expletive language?
Define, (actually define) the "stability" and "energy" of a compound
Are all passive ability checks floors for active ability checks?
How to apply Coupon on the Specific Products in Magento 2?
Discount coupon is not working for minimum subtotalMagento model extension experiment, return: “class does not exist”Is the salesrule_coupon “expiration_date” field used for anything?Doesn't apply coupon on the already discount productsMagento 2.1 Create a filter in the product grid by new attributeHow to apply coupon code if specific products are available on the cart?Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.2.5 Mysql add a coupon cart rule to customers accountApply discount on specific product using coupon Magento2Set Coupen for specific Products. Magento 2
I want to apply the coupon on the specific product I tried:
use MagentoSalesRuleModelRule;
public function __construct(
MagentoFrameworkAppHelperContext $helpercontext,
Rule $rule,
)
$this->_rule = $rule;
parent::__construct($helpercontext);
public function setCoupon()
// $this->_state->setAreaCode('adminhtml');
// $this->_state->setAreaCode('frontend');
$coupon['name'] = 'Offer_asad2';
$coupon['desc'] = 'Discount for vip signup coupon.';
$coupon['start'] = date('Y-m-d');
$coupon['end'] = '';
$coupon['max_redemptions'] = 1;
$coupon['discount_type'] ='by_fixed';
$coupon['discount_amount'] = 15;
$coupon['flag_is_free_shipping'] = 'no';
$coupon['redemptions'] = 1;
$coupon['code'] ='NL04-1234'; //this code will normally be autogenerated but i am hard coding for testing purposes
$this->_rule->setName($coupon['name'])
->setDescription($coupon['desc'])
->setFromDate($coupon['start'])
->setToDate($coupon['end'])
->setUsesPerCustomer($coupon['max_redemptions'])
->setCustomerGroupIds(array('0','1','2','3',))
->setIsActive(1)
->setSimpleAction($coupon['discount_type'])
->setDiscountAmount($coupon['discount_amount'])
->setDiscountQty(1)
->setApplyToShipping($coupon['flag_is_free_shipping'])
->setTimesUsed($coupon['redemptions'])
->setWebsiteIds(array('1'))
->setCouponType(2)
// ->setProductIds(array(1,2,3))
// ->setProductIds(array('1','2','3'))
->setProductIds(1)
->setCouponCode($coupon['code'])
->setUsesPerCoupon(NULL);
$this->_rule->save();
Now the issue is this code is applying on every single product->setProductIds(array(1,2,3)) and ->setProductIds(array('1','2','3')) but this is not working for me,
How can I apply the I set the coupon for the specific products?
magento2 programmatically coupon helper
|
show 2 more comments
I want to apply the coupon on the specific product I tried:
use MagentoSalesRuleModelRule;
public function __construct(
MagentoFrameworkAppHelperContext $helpercontext,
Rule $rule,
)
$this->_rule = $rule;
parent::__construct($helpercontext);
public function setCoupon()
// $this->_state->setAreaCode('adminhtml');
// $this->_state->setAreaCode('frontend');
$coupon['name'] = 'Offer_asad2';
$coupon['desc'] = 'Discount for vip signup coupon.';
$coupon['start'] = date('Y-m-d');
$coupon['end'] = '';
$coupon['max_redemptions'] = 1;
$coupon['discount_type'] ='by_fixed';
$coupon['discount_amount'] = 15;
$coupon['flag_is_free_shipping'] = 'no';
$coupon['redemptions'] = 1;
$coupon['code'] ='NL04-1234'; //this code will normally be autogenerated but i am hard coding for testing purposes
$this->_rule->setName($coupon['name'])
->setDescription($coupon['desc'])
->setFromDate($coupon['start'])
->setToDate($coupon['end'])
->setUsesPerCustomer($coupon['max_redemptions'])
->setCustomerGroupIds(array('0','1','2','3',))
->setIsActive(1)
->setSimpleAction($coupon['discount_type'])
->setDiscountAmount($coupon['discount_amount'])
->setDiscountQty(1)
->setApplyToShipping($coupon['flag_is_free_shipping'])
->setTimesUsed($coupon['redemptions'])
->setWebsiteIds(array('1'))
->setCouponType(2)
// ->setProductIds(array(1,2,3))
// ->setProductIds(array('1','2','3'))
->setProductIds(1)
->setCouponCode($coupon['code'])
->setUsesPerCoupon(NULL);
$this->_rule->save();
Now the issue is this code is applying on every single product->setProductIds(array(1,2,3)) and ->setProductIds(array('1','2','3')) but this is not working for me,
How can I apply the I set the coupon for the specific products?
magento2 programmatically coupon helper
usesetProductId, without 's'
– magefms
14 hours ago
you use it for one specific product but for more (array of)product, you use with 's'.
– magefms
14 hours ago
Yeah at the above scenario its I write it setProductIds n I pass the single product value but at that scenario it not gives me any error but in other cases as I mention above giver me an error Array to String how can I solve this?
– Asad Khan
13 hours ago
ahh okay, you have to put it inside bracket to indicate it as an array like this: setProductIds([1, 2, 3])
– magefms
13 hours ago
Sir Still have the same Problem Notice: Array to string conversion in /home2/mako/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
– Asad Khan
11 hours ago
|
show 2 more comments
I want to apply the coupon on the specific product I tried:
use MagentoSalesRuleModelRule;
public function __construct(
MagentoFrameworkAppHelperContext $helpercontext,
Rule $rule,
)
$this->_rule = $rule;
parent::__construct($helpercontext);
public function setCoupon()
// $this->_state->setAreaCode('adminhtml');
// $this->_state->setAreaCode('frontend');
$coupon['name'] = 'Offer_asad2';
$coupon['desc'] = 'Discount for vip signup coupon.';
$coupon['start'] = date('Y-m-d');
$coupon['end'] = '';
$coupon['max_redemptions'] = 1;
$coupon['discount_type'] ='by_fixed';
$coupon['discount_amount'] = 15;
$coupon['flag_is_free_shipping'] = 'no';
$coupon['redemptions'] = 1;
$coupon['code'] ='NL04-1234'; //this code will normally be autogenerated but i am hard coding for testing purposes
$this->_rule->setName($coupon['name'])
->setDescription($coupon['desc'])
->setFromDate($coupon['start'])
->setToDate($coupon['end'])
->setUsesPerCustomer($coupon['max_redemptions'])
->setCustomerGroupIds(array('0','1','2','3',))
->setIsActive(1)
->setSimpleAction($coupon['discount_type'])
->setDiscountAmount($coupon['discount_amount'])
->setDiscountQty(1)
->setApplyToShipping($coupon['flag_is_free_shipping'])
->setTimesUsed($coupon['redemptions'])
->setWebsiteIds(array('1'))
->setCouponType(2)
// ->setProductIds(array(1,2,3))
// ->setProductIds(array('1','2','3'))
->setProductIds(1)
->setCouponCode($coupon['code'])
->setUsesPerCoupon(NULL);
$this->_rule->save();
Now the issue is this code is applying on every single product->setProductIds(array(1,2,3)) and ->setProductIds(array('1','2','3')) but this is not working for me,
How can I apply the I set the coupon for the specific products?
magento2 programmatically coupon helper
I want to apply the coupon on the specific product I tried:
use MagentoSalesRuleModelRule;
public function __construct(
MagentoFrameworkAppHelperContext $helpercontext,
Rule $rule,
)
$this->_rule = $rule;
parent::__construct($helpercontext);
public function setCoupon()
// $this->_state->setAreaCode('adminhtml');
// $this->_state->setAreaCode('frontend');
$coupon['name'] = 'Offer_asad2';
$coupon['desc'] = 'Discount for vip signup coupon.';
$coupon['start'] = date('Y-m-d');
$coupon['end'] = '';
$coupon['max_redemptions'] = 1;
$coupon['discount_type'] ='by_fixed';
$coupon['discount_amount'] = 15;
$coupon['flag_is_free_shipping'] = 'no';
$coupon['redemptions'] = 1;
$coupon['code'] ='NL04-1234'; //this code will normally be autogenerated but i am hard coding for testing purposes
$this->_rule->setName($coupon['name'])
->setDescription($coupon['desc'])
->setFromDate($coupon['start'])
->setToDate($coupon['end'])
->setUsesPerCustomer($coupon['max_redemptions'])
->setCustomerGroupIds(array('0','1','2','3',))
->setIsActive(1)
->setSimpleAction($coupon['discount_type'])
->setDiscountAmount($coupon['discount_amount'])
->setDiscountQty(1)
->setApplyToShipping($coupon['flag_is_free_shipping'])
->setTimesUsed($coupon['redemptions'])
->setWebsiteIds(array('1'))
->setCouponType(2)
// ->setProductIds(array(1,2,3))
// ->setProductIds(array('1','2','3'))
->setProductIds(1)
->setCouponCode($coupon['code'])
->setUsesPerCoupon(NULL);
$this->_rule->save();
Now the issue is this code is applying on every single product->setProductIds(array(1,2,3)) and ->setProductIds(array('1','2','3')) but this is not working for me,
How can I apply the I set the coupon for the specific products?
magento2 programmatically coupon helper
magento2 programmatically coupon helper
edited 3 hours ago
Ronak Rathod
41010
41010
asked 14 hours ago
Asad KhanAsad Khan
1228
1228
usesetProductId, without 's'
– magefms
14 hours ago
you use it for one specific product but for more (array of)product, you use with 's'.
– magefms
14 hours ago
Yeah at the above scenario its I write it setProductIds n I pass the single product value but at that scenario it not gives me any error but in other cases as I mention above giver me an error Array to String how can I solve this?
– Asad Khan
13 hours ago
ahh okay, you have to put it inside bracket to indicate it as an array like this: setProductIds([1, 2, 3])
– magefms
13 hours ago
Sir Still have the same Problem Notice: Array to string conversion in /home2/mako/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
– Asad Khan
11 hours ago
|
show 2 more comments
usesetProductId, without 's'
– magefms
14 hours ago
you use it for one specific product but for more (array of)product, you use with 's'.
– magefms
14 hours ago
Yeah at the above scenario its I write it setProductIds n I pass the single product value but at that scenario it not gives me any error but in other cases as I mention above giver me an error Array to String how can I solve this?
– Asad Khan
13 hours ago
ahh okay, you have to put it inside bracket to indicate it as an array like this: setProductIds([1, 2, 3])
– magefms
13 hours ago
Sir Still have the same Problem Notice: Array to string conversion in /home2/mako/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
– Asad Khan
11 hours ago
use
setProductId, without 's'– magefms
14 hours ago
use
setProductId, without 's'– magefms
14 hours ago
you use it for one specific product but for more (array of)product, you use with 's'.
– magefms
14 hours ago
you use it for one specific product but for more (array of)product, you use with 's'.
– magefms
14 hours ago
Yeah at the above scenario its I write it setProductIds n I pass the single product value but at that scenario it not gives me any error but in other cases as I mention above giver me an error Array to String how can I solve this?
– Asad Khan
13 hours ago
Yeah at the above scenario its I write it setProductIds n I pass the single product value but at that scenario it not gives me any error but in other cases as I mention above giver me an error Array to String how can I solve this?
– Asad Khan
13 hours ago
ahh okay, you have to put it inside bracket to indicate it as an array like this: setProductIds([1, 2, 3])
– magefms
13 hours ago
ahh okay, you have to put it inside bracket to indicate it as an array like this: setProductIds([1, 2, 3])
– magefms
13 hours ago
Sir Still have the same Problem Notice: Array to string conversion in /home2/mako/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
– Asad Khan
11 hours ago
Sir Still have the same Problem Notice: Array to string conversion in /home2/mako/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
– Asad Khan
11 hours ago
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266095%2fhow-to-apply-coupon-on-the-specific-products-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266095%2fhow-to-apply-coupon-on-the-specific-products-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
use
setProductId, without 's'– magefms
14 hours ago
you use it for one specific product but for more (array of)product, you use with 's'.
– magefms
14 hours ago
Yeah at the above scenario its I write it setProductIds n I pass the single product value but at that scenario it not gives me any error but in other cases as I mention above giver me an error Array to String how can I solve this?
– Asad Khan
13 hours ago
ahh okay, you have to put it inside bracket to indicate it as an array like this: setProductIds([1, 2, 3])
– magefms
13 hours ago
Sir Still have the same Problem Notice: Array to string conversion in /home2/mako/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 228
– Asad Khan
11 hours ago