Jump to content

Úprava tabulky "Množstevní slevy"


Recommended Posts

Zdravím,
nastavuji u produktů množstevní slevy pro rozmezí cca 10 - 20, 21 - 50, atd.. Používám k tomu volbu Speciální ceny. Potřeboval bych ale tabulku ve front-endu upravit tak, aby bylo jasné že se jedná o rozmezí a ne o konkrétní počet kusů:

1292674545_2020-07-0913_29_41-Window.png.a285476b89beaeffde21f333d9ec8f31.png

Tzn. upravit šablonu výpisu na "od "proměnná Počet" ks". Tak jako je to v ostatních sloupcích. 

Nevíte někdo kde tuhle úpravu provést? 😀

Díky.

 

Share this post


Link to post
Share on other sites

No abych napsal pravdu, tak se s tím taky ser.... už hodinu.

Musel jsem si nechat uložit SQL dotaz z funkce getQuantityDiscounts a pak jej doplnit o podmínku.

No, ale dělá to bordel, když přidám jako první 5 druhý 10, třetí 15 a čtvrtý 1.

Pak se stane to, že mi poslední zobrazí od 15 do 1 😂

Takže nic no.

Share this post


Link to post
Share on other sites
10 minutes ago, Ladislav Němec said:

Jj to by neměl být problém. A při minimálním množství ke koupi - třeba 5ks také jede? 

A proč by nemělo, vždyť jde pouze o tabulku možných slev.

Share this post


Link to post
Share on other sites
public static function getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_product_attribute = null, $all_combinations = false, $id_customer = 0)
    {
        if (!SpecificPrice::isFeatureActive()) {
            return array();
        }

        $query_extra = self::computeExtraConditions($id_product, ((!$all_combinations) ? $id_product_attribute : null), $id_customer, null);
        $get_product_minimal_quantity = Db::getInstance()->getValue('SELECT minimal_quantity FROM `' . _DB_PREFIX_ . 'product` WHERE id_product = '.$id_product);
        $query = '
			SELECT *, (SELECT t.`from_quantity` FROM `' . _DB_PREFIX_ . 'specific_price` t WHERE (t.`id_product` = a.`id_product`) AND 
                (t.`id_specific_price` > a.`id_specific_price`)
                ORDER BY t.`id_specific_price` ASC, t.`from_quantity` ASC LIMIT 1) AS next_quantity,
					' . SpecificPrice::_getScoreQuery($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_customer) . '
				FROM `' . _DB_PREFIX_ . 'specific_price` a
				WHERE
					`id_shop` ' . self::formatIntInQuery(0, $id_shop) . ' AND
					`id_currency` ' . self::formatIntInQuery(0, $id_currency) . ' AND
					`id_country` ' . self::formatIntInQuery(0, $id_country) . ' AND
					`id_group` ' . self::formatIntInQuery(0, $id_group) . ' ' . $query_extra . ' 
					ORDER BY `from_quantity` ASC, `id_specific_price_rule` ASC, `score` DESC, `to` DESC, `from` DESC
		';
        
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query,false, false);


        $targeted_prices = array();
        $last_quantity = array();

        while ($specific_price = Db::getInstance()->nextRow($result)) {
            if (!isset($last_quantity[(int) $specific_price['id_product_attribute']])) {
                $last_quantity[(int) $specific_price['id_product_attribute']] = $specific_price['from_quantity'];
            } elseif ($last_quantity[(int) $specific_price['id_product_attribute']] == $specific_price['from_quantity']) {
                continue;
            }

            $last_quantity[(int) $specific_price['id_product_attribute']] = $specific_price['from_quantity'];
            if ($specific_price['from_quantity'] > 1) {
                $targeted_prices[] = $specific_price;
            }
        }

        return $targeted_prices;
    }

 

Share this post


Link to post
Share on other sites

a v tpl uprav na:

 {foreach from=$product.quantity_discounts item='quantity_discount' name='quantity_discounts'}
          <tr data-discount-type="{$quantity_discount.reduction_type}" data-discount="{$quantity_discount.real_value}" data-discount-quantity="{$quantity_discount.quantity}">
            <td>{l s='od' d='Shop.Theme.Catalog'} {$quantity_discount.quantity} {if $quantity_discount.next_quantity > 0} {l s='do' d='Shop.Theme.Catalog'} {$quantity_discount.next_quantity} {/if}</td>
            <td>{$quantity_discount.discount}</td>
            <td>{l s='Up to %discount%' d='Shop.Theme.Catalog' sprintf=['%discount%' => $quantity_discount.save]}</td>
          </tr>
        {/foreach}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More