// For all websites
$websites = $this->_storeManager->getWebsites();
foreach ($websites as $website) {
    $websiteUrl = $website->getDefaultStore()->getBaseUrl();
    $url = $websiteUrl . 'Couponcodeurl/cart/applycoupon';
    $url .= '?couponcode=' . urlencode($couponCode);
    $urls[$website->getId()][] = $url; // Store URL per website ID

In the above code, it gives all websites but I only want specific websites if I select test website then it only gives the test website cart price rule URL. Here is a shared screenshot in which I get the cart price rule with a website-wise URL, but I don't know how to get the URL from using auto-generated website-wise. https://i.imgur.com/5XNyAGA.png

  • You use the code of website collection, so it return all the website list. You need to modify the code and try to fetch the data of rule where you set the website while creations. Feb 12 at 9:48


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.