Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    May 2009
    Posts
    186
    Plugin Contributions
    0

    Default How to display price? "Starting at" prices are blank when attributes_qty_prices exist

    "Starting at" prices are blank on the product info page when attributes_qty_prices exist with the following admin configuration.
    I've been studying the code and am getting a little salty. Help, please?

    Prices are set in admin>Catalog>Categories/Products>Attribute Controller>edit option value> Attributes Qty Price Discount: (i.e., attributes_qty_prices)

    For example, shown below from the Table products_attributes here are the contents of attributes_qty_prices for 3 of the attributes associated with the product.

    3:7.35,9:7.20,29:6.83,49:6.39,99:5.88,299:5.51,499:5.14,999:5.07,9999:4.92
    3:9.17,9:8.98,29:8.53,49:7.98,99:7.33,299:6.88,499:6.42,999:6.33,9999:6.14
    3:11.20,9:10.98,29:10.42,49:9.75,99:8.96,299:8.40,499:7.84,999:7.73,9999:7.50

    I would therefore want the "Starting at" display price on the product info page to be $4.92 since it is the lowest qty price for the cheapest option.


    The Product Price is set to 0.00 (i.e., products_price = 0)

    The attribute prices are set to 0.00 (i.e., options_values_price = 0)

    The Product Priced by Attributes is set to YES

    The attribute prices are defined without the price prefix of +

    Attribute is Free When Product is Free: yes
    Apply Discounts Used by Product Special/Sale: yes
    Include in Base Price When Priced by Attributes: yes

    Used For Display Purposes Only: no
    Attribute Required for Text: no

  2. #2
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    Haven't looked at the includes/modules/attrbutes.php code and haven't used the quantity prices field on attributes, but typically the attribute's price is filled in to provide the minimum price for the product. I would think that the quantity discount would be populated in the same manner as when populating the quantity discounts as well, but again, that's just a thought. Otherwise the setup looks correct to support display of the minimum price for the product.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    What template are you using?

    Can you switch to the "classic green" to see what displays?
    Zen-Venom Get Bitten

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

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    Unfortunately, this is ignored by Zen-Cart . . . Consideration of attribute quantity discounts (i.e., attributes_qty_prices) for displaying the "Starting at" price is not a feature of Zen-Cart. Therefore, the "Starting at" price is blank. Suggestions on how to modify code?

    Here is Zen-Cart version 1.5.4. logic and code to display the "Starting at" price:

    tpl_product_info_display.php calls the Function zen_get_products_display_price
    Function zen_get_products_display_price calls the Function zen_get_products_base_price

    Both Functions are defined in the file named /includes/functions/functions_prices.php
    The file includes/modules/attrbutes.php does not seem to be involved.

    tpl_product_info_display.php . . .
    Code:
    <!--bof Product Price block -->
    <h2 id="productPrices" class="productGeneral">
    <?php
    // base price
      if ($show_onetime_charges_description == 'true') {
        $one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />';
      } else {
        $one_time = '';
      }
      echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
    ?></h2>
    <!--eof Product Price block -->

    Function zen_get_products_display_price . . .
    Code:
      function zen_get_products_display_price($products_id) {
        global $db, $currencies;
    
        $free_tag = "";
        $call_tag = "";
    
    // 0 = normal shopping
    // 1 = Login to shop
    // 2 = Can browse but no prices
        // verify display of prices
          switch (true) {
            case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
            // customer must be logged in to browse
            return '';
            break;
            case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
            // customer may browse but no prices
            return TEXT_LOGIN_FOR_PRICE_PRICE;
            break;
            case (CUSTOMERS_APPROVAL == '3' and TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != ''):
            // customer may browse but no prices
            return TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
            break;
            case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customer_id'] == ''):
            // customer must be logged in to browse
            return TEXT_AUTHORIZATION_PENDING_PRICE;
            break;
            case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customers_authorization'] > '0'):
            // customer must be logged in to browse
            return TEXT_AUTHORIZATION_PENDING_PRICE;
            break;
            default:
            // proceed normally
            break;
          }
    
    // show case only
        if (STORE_STATUS != '0') {
          if (STORE_STATUS == '1') {
            return '';
          }
        }
    
        // $new_fields = ', product_is_free, product_is_call, product_is_showroom_only';
        $product_check = $db->Execute("select products_tax_class_id, products_price, products_priced_by_attribute, product_is_free, product_is_call, products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'" . " limit 1");
    
        // no prices on Document General
        if ($product_check->fields['products_type'] == 3) {
          return '';
        }
    
        $show_display_price = '';
        $display_normal_price = zen_get_products_base_price($products_id);
        $display_special_price = zen_get_products_special_price($products_id, true);
        $display_sale_price = zen_get_products_special_price($products_id, false);
    
        $show_sale_discount = '';
        if (SHOW_SALE_DISCOUNT_STATUS == '1' and ($display_special_price != 0 or $display_sale_price != 0)) {
          if ($display_sale_price) {
            if (SHOW_SALE_DISCOUNT == 1) {
              if ($display_normal_price != 0) {
                $show_discount_amount = number_format(100 - (($display_sale_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
              } else {
                $show_discount_amount = '';
              }
              $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . $show_discount_amount . PRODUCT_PRICE_DISCOUNT_PERCENTAGE . '</span>';
    
            } else {
              $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . $currencies->display_price(($display_normal_price - $display_sale_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT . '</span>';
            }
          } else {
            if (SHOW_SALE_DISCOUNT == 1) {
              $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . number_format(100 - (($display_special_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS) . PRODUCT_PRICE_DISCOUNT_PERCENTAGE . '</span>';
            } else {
              $show_sale_discount = '<span class="productPriceDiscount">' . '<br />' . PRODUCT_PRICE_DISCOUNT_PREFIX . $currencies->display_price(($display_normal_price - $display_special_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . PRODUCT_PRICE_DISCOUNT_AMOUNT . '</span>';
            }
          }
        }
    
        if ($display_special_price) {
          $show_normal_price = '<span class="normalprice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . ' </span>';
          if ($display_sale_price && $display_sale_price != $display_special_price) {
            $show_special_price = '&nbsp;' . '<span class="productSpecialPriceSale">' . $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            if ($product_check->fields['product_is_free'] == '1') {
              $show_sale_price = '<br />' . '<span class="productSalePrice">' . PRODUCT_PRICE_SALE . '<s>' . $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</s>' . '</span>';
            } else {
              $show_sale_price = '<br />' . '<span class="productSalePrice">' . PRODUCT_PRICE_SALE . $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            }
          } else {
            if ($product_check->fields['product_is_free'] == '1') {
              $show_special_price = '&nbsp;' . '<span class="productSpecialPrice">' . '<s>' . $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</s>' . '</span>';
            } else {
              $show_special_price = '&nbsp;' . '<span class="productSpecialPrice">' . $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
            }
            $show_sale_price = '';
          }
        } else {
          if ($display_sale_price) {
            $show_normal_price = '<span class="normalprice">' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . ' </span>';
            $show_special_price = '';
            $show_sale_price = '<br />' . '<span class="productSalePrice">' . PRODUCT_PRICE_SALE . $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</span>';
          } else {
            if ($product_check->fields['product_is_free'] == '1') {
              $show_normal_price = '<s>' . $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) . '</s>';
            } else {
              $show_normal_price = $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id']));
            }
            $show_special_price = '';
            $show_sale_price = '';
          }
        }
    
        if ($display_normal_price == 0) {
          // don't show the $0.00
          $final_display_price = $show_special_price . $show_sale_price . $show_sale_discount;
        } else {
          $final_display_price = $show_normal_price . $show_special_price . $show_sale_price . $show_sale_discount;
        }
    
        // If Free, Show it
        if ($product_check->fields['product_is_free'] == '1') {
          if (OTHER_IMAGE_PRICE_IS_FREE_ON=='0') {
            $free_tag = '<br />' . PRODUCTS_PRICE_IS_FREE_TEXT;
          } else {
            $free_tag = '<br />' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_PRICE_IS_FREE, PRODUCTS_PRICE_IS_FREE_TEXT);
          }
        }
    
        // If Call for Price, Show it
        if ($product_check->fields['product_is_call']) {
          if (PRODUCTS_PRICE_IS_CALL_IMAGE_ON=='0') {
            $call_tag = '<br />' . PRODUCTS_PRICE_IS_CALL_FOR_PRICE_TEXT;
          } else {
            $call_tag = '<br />' . zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_CALL_FOR_PRICE, PRODUCTS_PRICE_IS_CALL_FOR_PRICE_TEXT);
          }
        }
    
        return $final_display_price . $free_tag . $call_tag;
      }
    Function zen_get_products_base_price . . .
    Code:
    ////
    // computes products_price + option groups lowest attributes price of each group when on
      function zen_get_products_base_price($products_id) {
        global $db;
          $product_check = $db->Execute("select products_price, products_priced_by_attribute from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
    
    // is there a products_price to add to attributes
          $products_price = $product_check->fields['products_price'];
    
          // do not select display only attributes and attributes_price_base_included is true
          $product_att_query = $db->Execute("select options_id, price_prefix, options_values_price, attributes_display_only, attributes_price_base_included, round(concat(price_prefix, options_values_price), 5) as value from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and attributes_display_only != '1' and attributes_price_base_included='1'". " order by options_id, value");
    
          $the_options_id= 'x';
          $the_base_price= 0;
    // add attributes price to price
          if ($product_check->fields['products_priced_by_attribute'] == '1' and $product_att_query->RecordCount() >= 1) {
            while (!$product_att_query->EOF) {
              if ( $the_options_id != $product_att_query->fields['options_id']) {
                $the_options_id = $product_att_query->fields['options_id'];
                $the_base_price += (($product_att_query->fields['price_prefix'] == '-') ? -1 : 1) * $product_att_query->fields['options_values_price'];
              }
              $product_att_query->MoveNext();
            }
    
            $the_base_price = $products_price + $the_base_price;
          } else {
            $the_base_price = $products_price;
          }
          return $the_base_price;
      }
    
    
    ////

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

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    Quote Originally Posted by kobra View Post
    What template are you using?

    Can you switch to the "classic green" to see what displays?
    Yes, same result (i.e., blank for Starting Price) with the "classic green" template. This is because, "The Display Price is made up of the lowest attribute price from each Option Name group" without regard to Prices that are set in admin>Catalog>Categories/Products>Attribute Controller>edit option value> Attributes Qty Price Discount: (i.e., attributes_qty_prices)

    Attached images show blank result

    Click image for larger version. 

Name:	Capture zencart display price 02b.jpg 
Views:	152 
Size:	63.3 KB 
ID:	16124Click image for larger version. 

Name:	Capture zencart display price 01b.jpg 
Views:	114 
Size:	79.7 KB 
ID:	16125

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

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    So, you can see from the above post, it is a feature of Zen-Cart that "Starting at" prices are blank on the product info page if products_price and options_values_price are zero even when attribute price attributes_qty_prices exists.
    How to modify code?

  7. #7
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    Where is your site
    Last edited by kobra; 19 Mar 2016 at 11:55 AM.
    Zen-Venom Get Bitten

  8. #8
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    A little curious. What is the price that you wish to see? I mean, normally when working with quantity pricing, the price of the item per unit goes down as more of the item are purchased. Also there is no real requirement to make all values positive... So given the various options available for selection/population, could it not be possible to still fulfill the various requirements to not have to add/change code? Instead let the math do the work? I thought there was either a FAQ or a link from a FAQ to a longer post, but there was an example showing how various multiplication and mathematics could be applied to obtain the desired result.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    Hi mc12345678, here are answers to your questions . . .

    Quote Originally Posted by mc12345678 View Post
    A little curious. What is the price that you wish to see?
    Post #1 shows a concrete example of the price I wish to see where I wrote, "I would therefore want the "Starting at" display price on the product info page to be $4.92 since it is the lowest qty price for the cheapest option."

    Quote Originally Posted by mc12345678 View Post
    could it not be possible to still fulfill the various requirements to not have to add/change code? Instead let the math do the work?
    It is not possible to "let the math do the work" since the relevant Zen-Cart code does not even access the data. That is, as I documented in post #4 and and demonstrated in post #5 circling in red an image of an example from the default installation of the Zen-Cart demo data showing the blank result (please read the text I added to the beginning of the product description in that "classic green" demonstration) . . .

    1. "Consideration of attribute quantity discounts (i.e., attributes_qty_prices) for displaying the 'Starting at' price is not a feature of Zen-Cart."

    2. "The Display Price is made up of the lowest attribute price from each Option Name group without regard to Prices that are set in admin>Catalog>Categories/Products>Attribute Controller>edit option value> Attributes Qty Price Discount: (i.e., attributes_qty_prices)"

    and in post #6

    3. "it is a feature of Zen-Cart that 'Starting at' prices are blank on the product info page if products_price and options_values_price are zero even when attribute price attributes_qty_prices exists."

    Suggestions on how to modify code?

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

    Default Re: How to display price? "Starting at" prices are blank when attributes_qty_prices e

    Hi kobra, what did you learn from this?


    Quote Originally Posted by kobra View Post
    What template are you using?

    Can you switch to the "classic green" to see what displays?
    Quote Originally Posted by Zean View Post
    Yes, same result (i.e., blank for Starting Price) with the "classic green" template. This is because, "The Display Price is made up of the lowest attribute price from each Option Name group" without regard to Prices that are set in admin>Catalog>Categories/Products>Attribute Controller>edit option value> Attributes Qty Price Discount: (i.e., attributes_qty_prices)

    Attached images show blank result

    Click image for larger version. 

Name:	Capture zencart display price 02b.jpg 
Views:	152 
Size:	63.3 KB 
ID:	16124Click image for larger version. 

Name:	Capture zencart display price 01b.jpg 
Views:	114 
Size:	79.7 KB 
ID:	16125
    Quote Originally Posted by Zean View Post
    So, you can see from the above post, it is a feature of Zen-Cart that "Starting at" prices are blank on the product info page if products_price and options_values_price are zero even when attribute price attributes_qty_prices exists.
    How to modify code?
    Suggestions on how to modify code?
    Last edited by Zean; 19 Mar 2016 at 07:56 PM. Reason: clarity

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v138a make wholesale "Sort by Price" display right when there special prices for products?
    By prettyodd in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 27 Nov 2012, 09:26 AM
  2. quantity discounts to display in "starting from"price
    By MARCOJIMJ in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 7 Jan 2011, 09:38 PM
  3. On Specials - How can I just display "20% off" or "save $x.xx", but not the price
    By candylotus in forum Setting Up Specials and SaleMaker
    Replies: 0
    Last Post: 24 Apr 2008, 12:44 AM
  4. "Starting At" price is empty OR price doubles when add to cart
    By infocom in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 22 Mar 2008, 10:40 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