Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multiple Sales/Specials Per Product and osC 2.3.4 Bootstrap


g2777

Recommended Posts

Hello,

Has anyone had any luck getting Multiple Sales Per Product for osCommerce 2.3 (http://addons.oscommerce.com/info/8593) working with the bootstrapped versions?
Specifically, the /catalog/specials.php and catalog/includes/modules/boxes/bm_specials.php files.

 

In specials.php I am instructed to find a line that begins:

echo '        <td align="center" width="33%"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id'])

except in the bootstrap version the only 'echo' statement in the whole file is the heading. Similar problem with the bm_specials.php file.

 

Is it possible to put these two together? It seems to me that specials.php creates a query that pulls the special items from the database and then calls product_listing.php to display them instead of duplicating the code. Is that right?

If that's the case I won't be able to install this add-on without re-writing specials.php. True? Or am I confused?

Many thanks in advance.

Graham

Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Link to comment
Share on other sites

specials.php creates a query that pulls the special items from the database and then calls product_listing.php to display them instead of duplicating the code. Is that right?

Right.

 

If that's the case I won't be able to install this add-on without re-writing specials.php. True?

No.

 

You don't want to rewrite core code to accomodate an addon, that's utter folly.

 

The addon needs to be rewritten.

Link to comment
Share on other sites

Thank you for your reply Gary.
However, I have already modified product_listing.php with very similar code from the instructions. In the standard 2.3.4, product_listing.php and specials.php both duplicate much of the same code and I assume that this is the reason that you condensed it to just a file inclusion as it was unnecessary, but the add-on assumed this was still the case and wants me to change parts that aren't there anymore.

 

You are right, of course. I should change the add-on to fit with the osC version. I just don't know how.

I'll take another look then and see if I can work round it.

 

Many thanks for your time.

Graham

Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Link to comment
Share on other sites

post here the instructions for the modifications needed to specials.php, we'll be able to figure it out easily

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

If you're willing to give it a shot then, by all means, feel free. My eternal thanks to you for even considering it.

 

Here are the instructions for modifying specials.php:

 

 

As with the changes in index.php these changes are required to prevent a product with multiple active defined sales from being listed more than once. In this case it also allows a search on prices to return the correct results.

 

16) In catalog/specials.php

 

16a) Around line 54 find the line that read as follows:

 

      echo '        <td align="center" width="33%"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $specials['products_image'], $specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id']) . '">' . $specials['products_name'] . '</a><br /><del>' . $currencies->display_price($specials['products_price'], tep_get_tax_rate($specials['products_tax_class_id'])) . '</del><br /><span class="productSpecialPrice">' . $currencies->display_price($specials['specials_new_products_price'], tep_get_tax_rate($specials['products_tax_class_id'])) . '</span></td>' . "\n";

 

and REPLACE it with the following:

 

      $expires = '';

      if ((DISPLAY_SALE_EXPIRATION_DATE == 'true') && ($specials['expires_date'] != '') && ($specials['expires_date'] != '0000-00-00 00:00:00')) {

        $expires = '<br /><small>' . TEXT_SALE_EXPIRES . tep_date_short($specials['expires_date']);

        if (DISPLAY_SALE_EXPIRATION_TIME == 'true') $expires .= ' @ ' . substr($specials['expires_date'], 11);

        $expires .= '</small>';

      }

      echo '        <td align="center" width="33%"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $specials['products_image'], $specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $specials['products_id']) . '">' . $specials['products_name'] . '</a><br /><del>' . $currencies->display_price($specials['products_price'], tep_get_tax_rate($specials['products_tax_class_id'])) . '</del><br /><span class="productSpecialPrice">' . $currencies->display_price($specials['specials_new_products_price'], tep_get_tax_rate($specials['products_tax_class_id'])) . $expires . '</span></td>' . "\n";

 

 

16b) Around line 28 find the line that read as follows:

 

  $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC";

 

and REPLACE it with the following:

 

  $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price, s.expires_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, (select * from (select products_id, specials_new_products_price, expires_date, sale_id, status, specials_date_added from " . TABLE_SPECIALS . " where status = 1 order by products_id, specials_new_products_price, expires_date) as t group by products_id) as s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = " . (int)$languages_id . (is_numeric($sale_id) ? " and s.sale_id = " . (int)$sale_id : "") . " and s.status = '1' order by s.specials_date_added DESC";

 

Once again this is required to prevent a product with multiple active defined sales from being listed more than once.

 

16c) Just above this you should see line that reads:

 

<h1><?php echo HEADING_TITLE; ?></h1>

 

Immediately BELOW this line add the following:

 

<div class="smallText" style="float: right">

<?php

    $sale_id = (isset($HTTP_GET_VARS['sale_id']) ? tep_db_prepare_input($HTTP_GET_VARS['sale_id']) : 'all');

    $sale_list = array(array('id' => 'all', 'text' => TEXT_ALL_ITEMS),

                       array('id' => '0', 'text' => TEXT_NOT_NAMED));

    $query = tep_db_query("select sale_id, sale_name from " . TABLE_SALES . " where status = 1 order by sale_name");

  while ($sale = tep_db_fetch_array($query))

    $sale_list[] = array('id' => $sale['sale_id'], 'text' => $sale['sale_name']);

  echo tep_draw_form('choose', FILENAME_SPECIALS, 'get') . TEXT_SHOW;

  echo tep_draw_pull_down_menu('sale_id', $sale_list,'', 'class="smallText" onchange="this.form.submit()"');

?></form>

</div>

<div style="clear: both"></div>

 

The bm_specials.php box file also needs the following change and that has the same problem:

 

 

18) In catalog/includes/modules/boxes/bm_specials.php

 

Around lines 37-41 you should see code that reads:

 

        if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {

          $data = '<div class="ui-widget infoBoxContainer">' .

                  '  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_SPECIALS) . '">' . MODULE_BOXES_SPECIALS_BOX_TITLE . '</a></div>' .

                  '  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br /><del>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</del><br /><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span></div>' .

                  '</div>';

 

REPLACE it with the following lines:

 

        if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price, s.expires_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, (select * from (select products_id, specials_new_products_price, expires_date, status, specials_date_added from " . TABLE_SPECIALS . " where status = 1 order by products_id, specials_new_products_price, expires_date) as t group by products_id) as s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {

          $expires = '';

          if ((DISPLAY_SALE_EXPIRATION_DATE == 'true') && ($random_product['expires_date'] != '') && ($random_product['expires_date'] != '0000-00-00 00:00:00')) {

            $expires = '<br /><small>' . TEXT_SALE_EXPIRES . tep_date_short($random_product['expires_date']);

            if (DISPLAY_SALE_EXPIRATION_TIME == 'true') $expires .= ' @ ' . substr($random_product['expires_date'], 11);

            $expires .= '</small>';

          }

          $data = '<div class="ui-widget infoBoxContainer">' .

                  '  <div class="ui-widget-header infoBoxHeading"><a href="' . tep_href_link(FILENAME_SPECIALS) . '">' . MODULE_BOXES_SPECIALS_BOX_TITLE . '</a></div>' .

                  '  <div class="ui-widget-content infoBoxContents" style="text-align: center;"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br /><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br /><del>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</del><br /><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . $expires . '</span></div>' .

                  '</div>';

 

This ensures that the correct current sale price is always displayed and displays the expiration if that is set to display.

 

 

There are a number of other files that still need to be modified but I don't know which ones or whether the changes are problematic or not as I haven't proceeded past the current issue yet.

If anyone does have any ideas then I will tip my hat to you (firstly; I will buy a hat). If I get it to work then I'll repackage the changes and upload a new version to the add-ons area.

 

Constantly stunned at how helpful everyone is,

Graham

Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Link to comment
Share on other sites

16a should be covered by the changes you made to product_listing

 

16b

 

just to get it to return the data for your sales, (you will loose the sorting options at this point, unless you figure out how to integrate it in detail)

replace

   $listing_sql line in specials.php

with (section 16c in instructions) - BUT change $specials_query_raw  into $listing_sql

  $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price, s.expires_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, (select * from (select products_id, specials_new_products_price, expires_date, sale_id, status, specials_date_added from " . TABLE_SPECIALS . " where status = 1 order by products_id, specials_new_products_price, expires_date) as t group by products_id) as s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = " . (int)$languages_id . (is_numeric($sale_id) ? " and s.sale_id = " . (int)$sale_id : "") . " and s.status = '1' order by s.specials_date_added DESC";

 

16c just apply as instructed

 

 

18 find the random product line

and replace with

        if ($random_product = tep_random_select("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price, s.expires_date from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, (select * from (select products_id, specials_new_products_price, expires_date, status, specials_date_added from " . TABLE_SPECIALS . " where status = 1 order by products_id, specials_new_products_price, expires_date) as t group by products_id) as s where p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added desc limit " . MAX_RANDOM_SELECT_SPECIALS)) {

          $expires = '';

          if ((DISPLAY_SALE_EXPIRATION_DATE == 'true') && ($random_product['expires_date'] != '') && ($random_product['expires_date'] != '0000-00-00 00:00:00')) {

            $expires = '<br /><small>' . TEXT_SALE_EXPIRES . tep_date_short($random_product['expires_date']);

            if (DISPLAY_SALE_EXPIRATION_TIME == 'true') $expires .= ' @ ' . substr($random_product['expires_date'], 11);

            $expires .= '</small>';

          }

 

 

 

Find

    if ($this->group == 'boxes_footer') {

 

the previous line ends in '</span>';

insert just before  $expires make sure to have $expires surrounded by dots

 

 

 

As for these sql changes, they seem very resource intensive sql queries, I personally are not sure if this is the proper way to do this. If your site slows down, that is the first place to investigate

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

I did it! Yay!

Thank you so much for your help. I had a problem getting the SQL statement in 16b working to begin with but in the end It was simply so that you can select the products associated with a particular sale by using the drop down list. So I used this:

$listing_sql = "select " . $select_column_list . " p.products_id, SUBSTRING_INDEX(pd.products_description, ' ', 20) as products_description, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . (is_numeric($sale_id) ? "' and s.sale_id = '" . (int)$sale_id : "") . "' and s.status = '1'";

Basically just replace

'" . (int)$languages_id . "'

with

'" . (int)$languages_id . (is_numeric($sale_id) ? "' and s.sale_id = '" . (int)$sale_id : "") . "'

in the original statement.

 

It works flawlessly as far as I can tell and I got to keep the sorting options.

 

Thank you again; to both of you.

 

Regards,

Graham

Not enough time in the day. Need a time machine...

 

Would build one, but not enough time. Ironically.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...