3

Is there any API in magento to get list of all coupons appreciable to a corresponding cart id.

can we get sale rules for a cart id and then find coupon through it

1
  • Hi if you got the solution please share I am having same problem
    – Satish V
    Apr 12, 2019 at 5:07

1 Answer 1

0
<?php 
$userData = array("username" => "admin", "password" => "153258ww");
$ch = curl_init("http://website.com/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Length: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$request = "http://website.com/rest/V1/carts/{cartId}/coupons";
$ch = curl_init($request);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));

$result = curl_exec($ch);
print_r(json_decode($result));
?>

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.