Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    131
    Plugin Contributions
    0

    Default Displaying price range for Quantity Discounts

    Hello

    I have spent the afternoon trying to get the product listing page to show the price range available for products with quantity discounts on them. After reading through a couple of related threads, I have successfully managed to do this with the following piece of code:

    PHP Code:
          <!--bof Product Price block -->
    <h2 id="productPrices" class="productGeneral">
    <?php
      
    if ($show_onetime_charges_description == 'true') {
        
    $one_time '<span >' TEXT_ONETIME_CHARGE_SYMBOL TEXT_ONETIME_CHARGE_DESCRIPTION '</span><br />';
      } else {
        
    $one_time '';
      }
    // qty discount
      
    $qty_discount zen_get_products_discount_price_qty((int)$_GET['products_id'],999999);
      
    $actual_price zen_get_products_actual_price((int)$_GET['products_id']);
      
    $base_price zen_get_products_base_price((int)$_GET['products_id']);
      if (
    $qty_discount $actual_price) {
      echo 
    $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price"><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id)) . ' - ' $currencies->display_price($actual_pricezen_get_tax_rate($products_tax_class_id)) . '</span>';
      } else {
    // base price
      
    echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price">' zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
      }
    ?></h2>
          <!--eof Product Price block -->
    My only issue with this is that this code leaves the base price of the product on the listing. As an example, we have a product with a price of $10 that is on special for $9 and has a quantity discount of $7.50 if you purchase 3 or more -- the code above produces the following:

    $10.00 $7.50 - $9.00

    This is fine for products with specials/sales on them, however I can't get it off products that don't have specials/sales on them.

    This is the code I've been trying to make work to remove the strike through on products without specials/sales:

    PHP Code:
          <!--bof Product Price block -->
    <h2 id="productPrices" class="productGeneral">
    <?php
      
    if ($show_onetime_charges_description == 'true') {
        
    $one_time '<span >' TEXT_ONETIME_CHARGE_SYMBOL TEXT_ONETIME_CHARGE_DESCRIPTION '</span><br />';
      } else {
        
    $one_time '';
      }
    // qty discount
      
    $qty_discount zen_get_products_discount_price_qty((int)$_GET['products_id'],999999);
      
    $actual_price zen_get_products_actual_price((int)$_GET['products_id']);
      
    $base_price zen_get_products_base_price((int)$_GET['products_id']);
      
    $special_price zen_get_products_special_price($products_idtrue);
      
    $sale_price zen_get_products_special_price($products_idfalse);
      
      if (
    $qty_discount $actual_price and ($special_price != or $sale_price != 1)) {
      echo 
    $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price"><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id)) . ' - ' $currencies->display_price($actual_pricezen_get_tax_rate($products_tax_class_id)) . '</span>';
      } elseif (
    $qty_discount $actual_price and ($special_price != or $sale_price != 0)) {
      echo 
    $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price">' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id)) . ' - ' $currencies->display_price($actual_pricezen_get_tax_rate($products_tax_class_id)) . '</span>';
      } else {
    // base price
      
    echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price">' zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
      }
    ?></h2>
          <!--eof Product Price block -->
    But this is doing nothing for me and just keeps the base price with a strike through and then follows with the quantity discounts:

    $10.00 $7.50 - $10.00

    Any ideas?
    Last edited by MortalWombat; 14 Mar 2016 at 08:30 AM.

  2. #2
    Join Date
    Mar 2016
    Posts
    14
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    the problem seems to be in the if ($qty_discount < $actual_price and ($special_price != 1 or $sale_price != 1)) {...} statement, try to replace with code below:

    PHP Code:
    if ($qty_discount $actual_price and ($special_price != or $sale_price != 1)) {
    echo 
    sprintf('%s%s<meta itemprop="priceCurrency" content="%s" /><span itemprop="price">%s</span>'$one_time, ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE ''), $_SESSION['currency'], ($actual_price != $base_price sprintf('<span class="normalprice">%s</span>'$currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id))) : '') . $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id)) . ' - ' $currencies->display_price($actual_pricezen_get_tax_rate($products_tax_class_id)));
    }
    .... 
    so, if $actual_price == $base_price, do not show the base_price with <span class="normalprice"></span>, problem can be solved
    Last edited by DrInt; 15 Mar 2016 at 09:10 AM.

  3. #3
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    131
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    OK, so using your logic, I tried a few different approaches and got it to work. Had to reverse the statements, but this is the working code to be placed in ../includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php:

    PHP Code:
          <!--bof Product Price block -->
    <h2 id="productPrices" class="productGeneral">
    <?php
      
    if ($show_onetime_charges_description == 'true') {
        
    $one_time '<span >' TEXT_ONETIME_CHARGE_SYMBOL TEXT_ONETIME_CHARGE_DESCRIPTION '</span><br />';
      } else {
        
    $one_time '';
      }
    // qty discount
      
    $qty_discount zen_get_products_discount_price_qty((int)$_GET['products_id'],999999);
      
    $actual_price zen_get_products_actual_price((int)$_GET['products_id']);
      
    $base_price zen_get_products_base_price((int)$_GET['products_id']);
    // regular price
      
    if ($qty_discount $actual_price and $actual_price == $base_price) {
      echo 
    $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price">' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id)) . ' - ' $currencies->display_price($actual_pricezen_get_tax_rate($products_tax_class_id)) . '</span>';
    // has special/sale
      
    } elseif ($qty_discount $actual_price and $base_price >= $actual_price) {
      echo 
    $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price"><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id)) . ' - ' $currencies->display_price($actual_pricezen_get_tax_rate($products_tax_class_id)) . '</span>';
      } else {
    // base price
      
    echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE '') . '<meta itemprop="priceCurrency" content="' $_SESSION['currency'] . '" />' '<span itemprop="price">' zen_get_products_display_price((int)$_GET['products_id']) . '</span>';
      }
    ?></h2>
          <!--eof Product Price block -->
    Thanks for your help, DrInt, and hopefully this is of some use to someone in the future

  4. #4
    Join Date
    May 2009
    Posts
    186
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    Thanks MortalWombat.

    Quick question . . .
    Are you setting your quantity discounts at the attribute level like I'm trying, via:
    1. admin>Catalog>Categories/Products>Attribute Controller>edit option value> Attributes Qty Price Discount: (i.e., attributes_qty_prices)
    or
    2. somewhere else? if so, where?

    Regarding #1 above, I am trying to display the Starting At price based on best discount at the attribute quantity level: https://www.zen-cart.com/showthread....y_prices-exist

  5. #5
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    131
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    Zean,

    As this store doesn't use attribute quantity discounts, these prices are set from the Products Price Manager and, as such, I have never even dabbled in an attempt to do what you're after.

    One thing I can suggest -- obviously, your products are using attributes, but does the quantity discount apply to all attribute combinations? As an example, if you have a product with colours Blue, Red and Green, and sizes, S, M, and L, do your quantity discounts apply to all the various combinations, no matter what the customer might pick? e.g. Blue, S, M, L; Red, S, M, L; Green, S, M, L.

    If this is the case, then perhaps you could just shift your quantity discounts from the attributes and onto the option in the Products Price Manager. Then you could use the code that I'm using.

    If not, e.g. quantity discount only applies to, say, Blue, S, then I'm afraid I'm not able to help you on this one.

  6. #6
    Join Date
    May 2009
    Posts
    186
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    Hi MortalWombat,

    You got it exactly right! From a business perspective I offer quantity discounts on only some attributes but not all attributes and that's why I'm using Attributes Qty Price Discount . . . admin>Catalog>Categories/Products>Attribute Controller>edit option value> Attributes Qty Price Discount: (i.e., field named attributes_qty_prices) instead of Products Price Manager. I thought it was not such a special and unique business need. It was a big task just to encode thousands of attributes_qty_prices. Afterwards, I found out about the limited and even counter intuitive roll it plays in Zen-Cart.

    Unfortunately, it appears that Attributes Qty Price Discount is a less fully developed and not properly integrated area of Zen-Cart as compared to Products Price Manager. And, evidence to date seems to suggest there is not a lot of understanding/interest in this area among current posters to the Forum that otherwise have the ability to help.

    Nevertheless, after weeks of hacking, last night I was able to achieve most my immediate goals in this area which additionally included other aspects of achieving the appearance of partial integration of Attributes Qty Price Discount, albeit inelegant and specific to my case, which is unfortunate because I my have been able to produce a better and more general solution with some guidance and/or collaboration with the experts that would have been useful to others.

    So, without further ado, I believe I'm about to ascend to the lofty status of Zen Follower transitioning from New Zenner which I have enjoyed for the last 7 years, with this my one hundredth post to the forum. I can't wait for the rite of passage ceremony and special rewards!

  7. #7
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    131
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    I'm very glad you were able to work something out, Zean. Although changes like these are not always as straight-forward or even as elegant as we might like, there's usually a way to do what we need to be done.

    I note that your solution wasn't posted on your forum thread... I'd be interested to take a look at what it was you did, as you never know -- maybe one day in the future I might be in your shoes.

    And welcome to the rank of Zen Follower

  8. #8
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    131
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    Further to the code I implemented above, I have managed to work in the same rule to show the lowest price available for any products with quantity discounts on product listing pages and modules.

    The following code will alter product prices on listing pages to show "As low as: $xx.xx" (lowest price available through quantity discounts). Please note I also added the following line to ../includes/languages/YOUR_TEMPLATE/english.php:
    PHP Code:
      define('TEXT_QTY_PRICE','As low as: '); 
    Files to edit:

    ../includes/modules/YOUR_TEMPLATE/product_listing.php
    ../includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_all_listing.php
    ../includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_featured_listing.php
    ../includes/templates/YOUR_TEMPLATE/templates/tpl_modules_products_new_listing.php
    ../includes/modules/pages/specials/main_template_vars.php
    ../includes/modules/YOUR_TEMPLATE/featured_products.php
    ../includes/modules/YOUR_TEMPLATE/new_products.php
    ../includes/modules/YOUR_TEMPLATE/specials_index.php
    ../includes/modules/YOUR_TEMPLATE/upcoming_products.php


    product_listing.php:
    Find:
    PHP Code:
            case 'PRODUCT_LIST_PRICE':
            
    $lc_price zen_get_products_display_price($listing->fields['products_id']) . '<br />';
            
    $lc_align 'right';
            
    $lc_text =  $lc_price
    Replace with:
    PHP Code:
        case 'PRODUCT_LIST_PRICE':
        
    $qty_discount zen_get_products_discount_price_qty((int)$listing->fields['products_id'],999999);
        
    $actual_price zen_get_products_actual_price((int)$listing->fields['products_id']);
        
    $base_price zen_get_products_base_price((int)$listing->fields['products_id']);
        
    $products_tax_class_id zen_products_lookup((int)$listing->fields['products_id'], 'products_tax_class_id');
    // regular price
      
    if ($qty_discount $actual_price and $base_price == $actual_price) {
        
    $lc_price '<span class="product-name">' TEXT_QTY_PRICE '</span>' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
    // has special/sale
      
    } elseif ($qty_discount $actual_price and $base_price != $actual_price) {
        
    $lc_price '<span class="product-name">' TEXT_QTY_PRICE '</span><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
      } else {
    // base price
        
    $lc_price zen_get_products_display_price($listing->fields['products_id']);
      }
        
    $lc_align 'right';
        
    $lc_text =  $lc_price
    tpl_modules_products_all_listing.php, tpl_modules_products_all_listing.php and tpl_modules_products_all_listing.php:
    Find:
    PHP Code:
          if ((PRODUCT_ALL_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($products_all->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
            
    $products_price zen_get_products_display_price($products_all->fields['products_id']);
            
    $display_products_price TEXT_PRICE ' ' $products_price str_repeat('<br clear="all" />'substr(PRODUCT_ALL_LIST_PRICE31)) . (zen_get_show_product_switch($products_all->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($products_all->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON '<br />' '') : '');
          } else {
            
    $display_products_price '';
          } 
    Replace with:
    PHP Code:
          if ((PRODUCT_ALL_LIST_PRICE != '0' and zen_get_products_allow_add_to_cart($products_all->fields['products_id']) == 'Y') and zen_check_show_prices() == true) {
          
    $qty_discount zen_get_products_discount_price_qty((int)$products_all->fields['products_id'],999999);
          
    $actual_price zen_get_products_actual_price((int)$products_all->fields['products_id']);
          
    $base_price zen_get_products_base_price((int)$products_all->fields['products_id']);
          
    $products_tax_class_id zen_products_lookup((int)$products_all->fields['products_id'], 'products_tax_class_id');
    // regular price
        
    if ($qty_discount $actual_price and $base_price == $actual_price) {
          
    $products_price '<span class="product-name">' TEXT_QTY_PRICE '</span>' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
    // has special/sale
        
    } elseif ($qty_discount $actual_price and $base_price != $actual_price) {
          
    $products_price '<span class="product-name">' TEXT_QTY_PRICE '</span><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
        } else {
    // base price
          
    $products_price zen_get_products_display_price($products_all->fields['products_id']);
        }
            
    $display_products_price TEXT_PRICE ' ' $products_price str_repeat('<br clear="all" />'substr(PRODUCT_ALL_LIST_PRICE31)) . (zen_get_show_product_switch($products_all->fields['products_id'], 'ALWAYS_FREE_SHIPPING_IMAGE_SWITCH') ? (zen_get_product_is_always_free_shipping($products_all->fields['products_id']) ? TEXT_PRODUCT_FREE_SHIPPING_ICON '<br />' '') : '');
          } else {
            
    $display_products_price '';
          } 
    Ensure you replace PRODUCT_ALL_LIST_PRICE and all instances of $products_all with the appropriate string for the file you're editing (PRODUCT_FEATURED_LIST_PRICE, $featured_products and PRODUCT_NEW_LIST_PRICE, $products_new).

    main_template_vars.php:
    Find:
    PHP Code:
        $list_box_contents = array();
        while (!
    $specials->EOF) {

          
    $products_price zen_get_products_display_price($specials->fields['products_id']); 
    Replace with:
    PHP Code:
        $list_box_contents = array();
        while (!
    $specials->EOF) {

          
    $qty_discount zen_get_products_discount_price_qty((int)$specials->fields['products_id'],999999);
          
    $actual_price zen_get_products_actual_price((int)$specials->fields['products_id']);
          
    $base_price zen_get_products_base_price((int)$specials->fields['products_id']);
          
    $products_tax_class_id zen_products_lookup((int)$specials->fields['products_id'], 'products_tax_class_id');
    // qty discount
        
    if ($qty_discount $actual_price) {
          
    $products_price '<span class="product-name">' TEXT_QTY_PRICE '</span><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
        } else {
    // base price
          
    $products_price zen_get_products_display_price($specials->fields['products_id']);
        } 
    featured_products.php, new_products.php, specials_index.php, upcoming_products.php
    Find:
    PHP Code:
      while (!$featured_products->EOF) {
        
    $products_price zen_get_products_display_price($featured_products->fields['products_id']); 
    Replace with:
    PHP Code:
      while (!$featured_products->EOF) {
        
    $qty_discount zen_get_products_discount_price_qty((int)$featured_products->fields['products_id'],999999);
        
    $actual_price zen_get_products_actual_price((int)$featured_products->fields['products_id']);
        
    $base_price zen_get_products_base_price((int)$featured_products->fields['products_id']);
        
    $products_tax_class_id zen_products_lookup((int)$featured_products->fields['products_id'], 'products_tax_class_id');
    // regular price
      
    if ($qty_discount $actual_price and $base_price == $actual_price) {
        
    $products_price '<span class="product-name">' TEXT_QTY_PRICE '</span>' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
    // has special/sale
      
    } elseif ($qty_discount $actual_price and $base_price != $actual_price) {
        
    $products_price '<span class="product-name">' TEXT_QTY_PRICE '</span><span class="normalprice">' $currencies->display_price($base_pricezen_get_tax_rate($products_tax_class_id)) . '</span> ' $currencies->display_price($qty_discountzen_get_tax_rate($products_tax_class_id));
      } else {
    // base price
        
    $products_price zen_get_products_display_price($featured_products->fields['products_id']);
      } 
    Again, ensure you replace all instances of $featured_products with the appropriate string for the file you're editing ($new_products, $specials_index and $expected).

  9. #9
    Join Date
    May 2009
    Posts
    186
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    Quote Originally Posted by MortalWombat View Post
    I'm very glad you were able to work something out, Zean. Although changes like these are not always as straight-forward or even as elegant as we might like, there's usually a way to do what we need to be done.

    I note that your solution wasn't posted on your forum thread... I'd be interested to take a look at what it was you did, as you never know -- maybe one day in the future I might be in your shoes.

    And welcome to the rank of Zen Follower
    Thanks MortalWombat.
    I posted the code in the thread here https://www.zen-cart.com/showthread....y_prices-exist

  10. #10
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    131
    Plugin Contributions
    0

    Default Re: Displaying price range for Quantity Discounts

    Quote Originally Posted by Zean View Post
    Thanks MortalWombat.
    I posted the code in the thread here https://www.zen-cart.com/showthread....y_prices-exist
    Looks good, Zean. Thanks for that

 

 

Similar Threads

  1. Replies: 17
    Last Post: 19 Feb 2013, 12:45 PM
  2. Quantity Discounts Question: Call For Price option?
    By ray-the-otter in forum General Questions
    Replies: 2
    Last Post: 1 Dec 2011, 12:30 PM
  3. Product quantity price discounts & group discounts
    By Richard.Tung in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 11 Jun 2009, 03:24 PM
  4. Price range for price by attributes
    By tigergirl in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 27 Sep 2007, 05:58 PM
  5. Changing price range to time range (in Advanced Search)
    By jeffmic in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Sep 2006, 07:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR