Jump to content

Archived

This topic is now archived and is closed to further replies.

NodsDorf

Little Help with Quanity Price Break Query for 2.3.1

Recommended Posts

I'm implementing QPB from 2.2 instructions and as far as I can tell was able to get it all done except one part in the \catalog\includes\modules\product_listing.php

 

Instructions Say to replace this switch

	    switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
	    $lc_align = '';
	    $lc_text = ' ' . $listing['products_model'] . ' ';
	    break;
	  case 'PRODUCT_LIST_NAME':
.
.
.
.
.
.
	  case 'PRODUCT_LIST_BUY_NOW':
	    $lc_align = 'center';
	    $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
	    break;
    }

 

Which is actually this switch in 2.3.1

switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
	    $prod_list_contents .= '	    <td>' . $listing['products_model'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_NAME':
	    if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
	    } else {
		  $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
	    }
	    break;
	  case 'PRODUCT_LIST_MANUFACTURER':
	    $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></td>';
	    break;
	  case 'PRODUCT_LIST_PRICE':
	    if (tep_not_null($listing['specials_new_products_price'])) {
		  $prod_list_contents .= '	    <td align="right"><del>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>';
	    } else {
		  $prod_list_contents .= '	    <td align="right">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
	    }
	    break;
	  case 'PRODUCT_LIST_QUANTITY':
	    $prod_list_contents .= '	    <td align="right">' . $listing['products_quantity'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_WEIGHT':
	    $prod_list_contents .= '	    <td align="right">' . $listing['products_weight'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_IMAGE':
	    if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '	    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	    } else {
		  $prod_list_contents .= '	    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	    }
	    break;
	  case 'PRODUCT_LIST_BUY_NOW':
	    $prod_list_contents .= '	    <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
	    break;
    }

 

With:

	    switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
	    $lc_align = '';
	    $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
	    break;
	  case 'PRODUCT_LIST_NAME':
	    $lc_align = '';
	    if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
	    } else {
		  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
	    }
	    break;
	  case 'PRODUCT_LIST_MANUFACTURER':
	    $lc_align = '';
	    $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
	    break;
	  case 'PRODUCT_LIST_PRICE':
	    $lc_align = 'right';
	    $price_breaks_from_listing = array();
	    if (isset($price_breaks_array[$listing[$x]['products_id']])) {
		  $price_breaks_from_listing = $price_breaks_array[$listing[$x]['products_id']];
	    }
	    $pf->loadProduct($listing[$x]['products_id'], $languages_id, $listing[$x], $price_breaks_from_listing);
	    $lc_text = $pf->getPriceStringShort();
	    break;
	  case 'PRODUCT_LIST_QUANTITY':
	    $lc_align = 'right';
	    $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
	    break;
	  case 'PRODUCT_LIST_WEIGHT':
	    $lc_align = 'right';
	    $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
	    break;
	  case 'PRODUCT_LIST_IMAGE':
	    $lc_align = 'center';
	    if (isset($HTTP_GET_VARS['manufacturers_id'])) {
		  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
	    } else {
		  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
	    }
	    break;
	  case 'PRODUCT_LIST_BUY_NOW':
	    $lc_align = 'center';
	    $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
	    break;
    }
// EOF qpbpp

 

The problem I'm having is with the case statement case 'PRODUCT_LIST_PRICE':

 

The closest as I've been able to come is with this:

 
case 'PRODUCT_LIST_PRICE':
	  if (tep_not_null($listing['specials_new_products_price'])) {
		  $prod_list_contents .= '	    <td align="right"><del>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>';
	    } else {
		  $prod_list_contents .= '	    <td align="right">' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
	    }
	    break;

 

 

 

Which gives the actual price, not the discounted price.

 

As you can see the instructioner kinda glossed over the code I was suppose to remove, but I'm sure I need to add

$price_breaks_from_listing = array();

if (isset($price_breaks_array[$listing[$x]['products_id']])) {

$price_breaks_from_listing = $price_breaks_array[$listing[$x]['products_id']];

}

$pf->loadProduct($listing[$x]['products_id'], $languages_id, $listing[$x], $price_breaks_from_listing);

$lc_text = $pf->getPriceStringShort();

in some sort of fashion since its actually pulling the price data

 

Any help is appreciated.

 

Once its fixed I should be able to update the add-on instructions for 2.3.1

 

Thanks,

Share this post


Link to post
Share on other sites

Okay figured it out...

In 2.3.1

Find this:

switch ($column_list[$col]) {
                 case 'PRODUCT_LIST_MODEL':
                   $prod_list_contents .= '        <td>' . $listing['products_model'] . '</td>';
                   break;
                 case 'PRODUCT_LIST_NAME':
                   if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
                         $prod_list_contents .= '          <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
                   } else {
                         $prod_list_contents .= '          <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a></td>';
                   }
                   break;
                 case 'PRODUCT_LIST_MANUFACTURER':
                   $prod_list_contents .= '        <td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a></td>';
                   break;
                 case 'PRODUCT_LIST_PRICE':
                   if (tep_not_null($listing['specials_new_products_price'])) {
                         $prod_list_contents .= '          <td align="right"><del>' .  $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span></td>';
                   } else {
                         $prod_list_contents .= '          <td align="right">' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</td>';
                   }
                   break;
                 case 'PRODUCT_LIST_QUANTITY':
                   $prod_list_contents .= '        <td align="right">' . $listing['products_quantity'] . '</td>';
                   break;
                 case 'PRODUCT_LIST_WEIGHT':
                   $prod_list_contents .= '        <td align="right">' . $listing['products_weight'] . '</td>';
                   break;
                 case 'PRODUCT_LIST_IMAGE':
                   if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
                         $prod_list_contents .= '          <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
                   } else {
                         $prod_list_contents .= '          <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
                   }
                   break;
                 case 'PRODUCT_LIST_BUY_NOW':
                   $prod_list_contents .= '        <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
                   break;
           }

 

Replace with this:

switch ($column_list[$col]) {
	  case 'PRODUCT_LIST_MODEL':
	    $prod_list_contents .= '	    <td>' . $listing[$x]['products_model'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_NAME':
	    if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a></td>';
	    } else {
		  $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a></td>';
	    }
	    break;
	  case 'PRODUCT_LIST_MANUFACTURER':
	    $prod_list_contents .= '	    <td><a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a></td>';
	    break;
    case 'PRODUCT_LIST_PRICE':
		 $price_breaks_from_listing = array();
			    if (isset($price_breaks_array[$listing[$x]['products_id']])) {
					  $price_breaks_from_listing = $price_breaks_array[$listing[$x]['products_id']];
			    }
			    $pf->loadProduct($listing[$x]['products_id'], $languages_id, $listing[$x], $price_breaks_from_listing);
           $prod_list_contents .= ' <td align="right">' .  $pf->getPriceStringShort(). '</td>';
	    break;
	  case 'PRODUCT_LIST_QUANTITY':
	    $prod_list_contents .= '	    <td align="right">' . $listing[$x]['products_quantity'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_WEIGHT':
	    $prod_list_contents .= '	    <td align="right">' . $listing[$x]['products_weight'] . '</td>';
	    break;
	  case 'PRODUCT_LIST_IMAGE':
	    if (isset($HTTP_GET_VARS['manufacturers_id'])  && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
		  $prod_list_contents .= '	    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	    } else {
		  $prod_list_contents .= '	    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>';
	    }
	    break;
	  case 'PRODUCT_LIST_BUY_NOW':
	    $prod_list_contents .= '	    <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])) . '</td>';
	    break;
    }

 

This should now show the "From $x.xx" on the product_listing results page.

 

I ran into a new problem with the cart not calculating correctly when a quantity break is reached. I'm working on that issue then I'll try and release an update for 2.3.1 users.

Share this post


Link to post
Share on other sites

×