useDiscount example

$this->config = $config;
    }

    /** * @return string */
    public function getSelection(ShopContextInterface $context)
    {
        $current = $context->getCurrentCustomerGroup();
        $currency = $context->getCurrency();

        $discount = $current->useDiscount() ? $current->getPercentageDiscount() : 0;

        $considerMinPurchase = $this->config->get('calculateCheapestPriceWithMinPurchase');

        $taxCase = $this->buildTaxCase($context);

        // Rounded to filter this value correctly         // => 2,99999999 displayed as 3,- € but won't be displayed with a filter on price >= 3,- €         $selection = 'ROUND(' .

            // Customer group price (with fallback switch)             'prices.price' .

            

        $customerGroup = $context->getCurrentCustomerGroup();

        /* * Basket discount calculation: * * Check if a global basket discount is configured and reduce the price * by the percentage discount value of the current customer group. */
        if ($customerGroup->useDiscount() && $customerGroup->getPercentageDiscount()) {
            $price -= ($price / 100 * $customerGroup->getPercentageDiscount());
        }

        /* * Currency calculation: * If the customer is currently in a sub shop with another currency, like dollar, * we have to calculate the price for the other currency. */
        $price *= $context->getCurrency()->getFactor();

        /* * check if the customer group should see gross prices. */
public function getSelection(ShopContextInterface $context)
    {
        $fallback = $context->getFallbackCustomerGroup();
        $current = $context->getCurrentCustomerGroup();
        $currency = $context->getCurrency();

        $priceField = 'defaultPrice.price';
        if ($fallback->getId() != $current->getId()) {
            $priceField = 'IFNULL(customerPrice.price, defaultPrice.price)';
        }

        $discount = $current->useDiscount() ? $current->getPercentageDiscount() : 0;

        $considerMinPurchase = $this->config->get('calculateCheapestPriceWithMinPurchase');

        $taxCase = $this->buildTaxCase($context);

        // rounded to filter this value correctly         // => 2,99999999 displayed as 3,- € but won't be displayed with a filter on price >= 3,- €         return 'ROUND(' .

            // customer group price (with fallback switch)             $priceField .

            
Home | Imprint | This part of the site doesn't use cookies.