Jump to content
delete13

jQuery/Ajax Shopping Cart

Recommended Posts

This is an awesome add-on. I am using it now, however there is a slight problem. The hover function does not seem to be working in internet explorer. It does work with firefox and chrome however. Any solution to this?

Share this post


Link to post
Share on other sites

This is an awesome add-on. I am using it now, however there is a slight problem. The hover function does not seem to be working in internet explorer. It does work with firefox and chrome however. Any solution to this?

 

You mean the Drag & Drop thing? What part of it isn't working?

Doesn't the product get added to the cart or is it something wrong with the animation?

 

I don't use Windows so I have limited testing capabilities. Normally, I try to repress that there is anything called Internet Explorer and hope for the best! :P

But this should be a quick fix since jQuery is supported by most of the IE releases, I think? Which Internet Explorer are you testing with?

Share this post


Link to post
Share on other sites

Another important update that everybody should apply:

 

In ./includes/template_top.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?>>
<head>

 

Move this code to the absolute top of the page, otherwise the browser wont detect the correct doctype. This might fix your problem, Dr Lemons.

Share this post


Link to post
Share on other sites

I hope you can help me too.

 

I have successfully installed jQuery Shopping Cart 2.3.3 Rev 3

 

However, I still have the issue that is mentioned at the beginning of this topic. When I add a product to the shopping cart, the shopping_cart.php page is loaded INSIDE the infobox.

 

How do I solve this? The rest of the contribution works perfectly.

Share this post


Link to post
Share on other sites

I hope you can help me too.

 

I have successfully installed jQuery Shopping Cart 2.3.3 Rev 3

 

However, I still have the issue that is mentioned at the beginning of this topic. When I add a product to the shopping cart, the shopping_cart.php page is loaded INSIDE the infobox.

 

How do I solve this? The rest of the contribution works perfectly.

 

Hello igerads,

 

Sorry for the late reply, perhaps you solved this yourself already?

 

Can you try with applying the update that I have uploaded and see if you get the same type of error.

 

If that doesn't work could you please check if the error occurs at both when you are at shopping_cart.php & product_info.php

Share this post


Link to post
Share on other sites

if someone could be kind enough,

 

To tell me which code updates the price via quantity dynamically in the cart?

I would like to have the exact same quantity box with + and - and dynamic ajax update of price and attributes except this time for the Product Info page if possible.

 

any help on this would be greatly appreciated.

Edited by vampirehunter

Share this post


Link to post
Share on other sites

Hello igerads,

 

Sorry for the late reply, perhaps you solved this yourself already?

 

Can you try with applying the update that I have uploaded and see if you get the same type of error.

 

If that doesn't work could you please check if the error occurs at both when you are at shopping_cart.php & product_info.php

 

Thanks so much, it works now!

Share this post


Link to post
Share on other sites

@@Dr. Rolex

Hi! Your addon is cool! Especially flying effect!!!

I have a problem, for SEO purposes I installed KissIT Image Thumbnailer, but flying effect doesnt work any more.... How can I solve that problem?? ?

 

Make sure that your images have the ID tag "cart-image-[product_id]", so if the products_id is 28 then the ID tag on that product image needs to be "cart-image-28".

 

You add these parameters on the fifth position of the tep_image function, so it looks something like this:

 

tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), null, null, 'class="draggable" rel="'.(int)$product_info['products_id'].'" data-id="options-" id="cart-image-' . (int)$product_info['products_id'] . '"')

If you can't get this to work, then you could try to add a <div> around the image with the same ID tag. E.g.:

 

<div id="cart-image-<?php echo (int)$product_info['products_id']; ?>">
[Your image here]
</div>

Share this post


Link to post
Share on other sites

Hello.

 

This seems to be a great contribution! Thank you!

 

I'm trying to install it on the new version 2.3.4 but there's a lot of bugs in IE9 to the point it messes up the layout and it just won't work correctly! In Firefox 31 it works fairly well, although there's still some bugs especially on products page.

Is there any updated installation instructions for version 2.3.4?

 

TIA for any clues on this.


Patty

Share this post


Link to post
Share on other sites

I hope you can help me too.

 

I have successfully installed jQuery Shopping Cart 2.3.3 Rev 3

 

However, I still have the issue that is mentioned at the beginning of this topic. When I add a product to the shopping cart, the shopping_cart.php page is loaded INSIDE the infobox.

 

How do I solve this? The rest of the contribution works perfectly.

Solution: http://forums.oscommerce.com/topic/361227-jqueryajax-shopping-cart/?p=1660224

 

"The solution is to change the store admin panel options

"Show cart after adding the product" to TRUE."

Edited by Patty

Patty

Share this post


Link to post
Share on other sites

Still trying to make it work on IE 9.

 

If I remove the contributions bm_shopping_cart.php file, layout in IE 9 goes back to normal. I put the file back in, the right colum goes underneath the left column and layout messes up again. Changing quantity in shopping_cart.php by clicking on +- buttons will not work.

 

Also I get the following errors:

Line: 24
Character: 2
Code: 0
Error Message: 'IMAGE_BUTTON_DELETE' is undefined
URL: http://localhost/MyWebs/catalog/ext/modules/shopping_cart/jquery-oscart.js?1200
Line: 199
Character: 3
Code: 0
Error Message: Unable to get value of the property 'replace': object is null or undefined
URL: http://localhost/MyWebs/catalog/ext/modules/shopping_cart/jquery-oscart.js?1200

So I can't delete any products from inside the cart.

 

I'm not a coder, I'm just trying to put this together for a client. Can anybody help? Dr. Rolex, are you still supporting this contribution? Help please!


Patty

Share this post


Link to post
Share on other sites

 

Still another error (sorry for the multiple posts, I cannot edit my posts):

Line: 14
Character: 1
Code: 0
Error Message: Object doesn't support property or method 'getAttribute'
URL: http://localhost/MyWebs/catalog/ext/modules/shopping_cart/jquery-oscart.js?1200

 

Hello Patricia,

 

It was a long time ago I worked on this Add-On, but I will take a look at it on a osC 2.3.4 installation and see what needs to be modified.

 

Regarding IE support, IE9 and above should work, IE8 and older versions I don't know what to do to make it work. There's usually some hack or other degradation that can be used instead of the original code.

Google the error messages you get in IE and you will probably find something.

 

But let's get the Add-On working on the modern browsers first. I'll get back when I have tested on osC 2.3.4..

Share this post


Link to post
Share on other sites

Download and use these files from jQuery Shopping Cart 2.3.3 Rev 3. The package uploaded on 28 Jun 2013.

 

./ext/modules/shopping_cart/jquery-oscart.js

./shopping_cart.php

./includes/modules/boxes/bm_shopping_cart.php

 

Change product_info.php to the code below and the Add-On should work in Firefox & Chrome on osC 2.3.4, at least it does for me. ;)

 

I don't use Windows so I can't test with IE right now. But, apparently according to my old instructions, the Add-On worked on both IE8 and IE9 before so it should work now as well.

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2014 osCommerce

  Released under the GNU General Public License
*/

  require 'includes/application_top.php';

  if ( !isset( $HTTP_GET_VARS['products_id'] ) ) {
    tep_redirect( tep_href_link( FILENAME_DEFAULT ) );
  }

  require DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO;

  $product_check_query = tep_db_query( "select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'" );
  $product_check = tep_db_fetch_array( $product_check_query );

  require DIR_WS_INCLUDES . 'template_top.php';

  if ( $product_check['total'] < 1 ) {
  ?>

  <div class="contentContainer">
    <div class="contentText">
      <?php echo TEXT_PRODUCT_NOT_FOUND; ?>
    </div>

    <div style="float: right;">
      <?php echo tep_draw_button( IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link( FILENAME_DEFAULT ) ); ?>
    </div>
  </div>

  <?php
  } else {
    $product_info_query = tep_db_query( "select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'" );
    $product_info = tep_db_fetch_array( $product_info_query );

    tep_db_query( "update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'" );

    if ( $new_price = tep_get_products_special_price( $product_info['products_id'] ) ) {
      $products_price = '<del>' . $currencies->display_price( $product_info['products_price'], tep_get_tax_rate( $product_info['products_tax_class_id'] ) ) . '</del> <span class="productSpecialPrice">' . $currencies->display_price( $new_price, tep_get_tax_rate( $product_info['products_tax_class_id'] ) ) . '</span>';
    } else {
      $products_price = $currencies->display_price( $product_info['products_price'], tep_get_tax_rate( $product_info['products_tax_class_id'] ) );
    }

    if ( tep_not_null( $product_info['products_model'] ) ) {
      $products_name = $product_info['products_name'] . '<br /><span class="smallText">[' . $product_info['products_model'] . ']</span>';
    } else {
      $products_name = $product_info['products_name'];
    }
  ?>

  <div>
    <h1 style="float: right;"><?php echo $products_price; ?></h1>
    <h1><?php echo $products_name; ?></h1>
  </div>

  <div class="contentContainer">
    <div class="contentText">

  <?php
    if ( tep_not_null( $product_info['products_image'] ) ) {
      $photoset_layout = '1';

      $pi_query = tep_db_query( "select image, htmlcontent from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order" );
      $pi_total = tep_db_num_rows( $pi_query );

      if ( $pi_total > 0 ) {
        $pi_sub = $pi_total-1;

        while ( $pi_sub > 5 ) {
          $photoset_layout .= 5;
          $pi_sub = $pi_sub-5;
        }

        if ( $pi_sub > 0 ) {
          $photoset_layout .= ( $pi_total > 5 ) ? 5 : $pi_sub;
        }
  ?>

      <div id="piGal">

  <?php
        $pi_counter = 0;
        $pi_html = array();

        while ( $pi = tep_db_fetch_array( $pi_query ) ) {
          $pi_counter++;

          if ( tep_not_null( $pi['htmlcontent'] ) ) {
            $pi_html[] = '<div id="piGalDiv_' . $pi_counter . '">' . $pi['htmlcontent'] . '</div>';
          }

          echo tep_image( DIR_WS_IMAGES . $pi['image'], '', '', '', 'rel="'.(int)$product_info['products_id'].'" data-id="options-" id="'.(int)$product_info['products_id'].'" class="draggable gallery" id="cart-image-' . $pi_counter . '"' );
        }
  ?>

      </div>

  <?php
        if ( !empty( $pi_html ) ) {
          echo '    <div style="display: none;">' . implode( '', $pi_html ) . '</div>';
        }
      } else {
  ?>

      <div id="piGal">
        <?php echo tep_image( DIR_WS_IMAGES . $product_info['products_image'], addslashes( $product_info['products_name'] ), '', '', 'class="draggable" rel="'.(int)$product_info['products_id'].'" data-id="options-" id="' . (int)$product_info['products_id'] . '"' ); ?>
      </div>

  <?php
      }
    }
  ?>

  <script type="text/javascript">
  var productId = <?php echo (int)$product_info['products_id']; ?>;

  $(function(){

    $('#piGal').css({
      'visibility': 'hidden'
    });

    $('#piGal').photosetGrid({
      layout: '<?php echo $photoset_layout; ?>',
      width: '250px',
      highresLinks: true,
      rel: 'pigallery',
      onComplete: function() {
        $('#piGal').css({ 'visibility': 'visible'});

        $('#piGal a').colorbox({
          maxHeight: '90%',
          maxWidth: '90%',
          rel: 'pigallery'
        });

        $('#piGal img').each(function() {
          var imgid = $(this).attr('id').substring(9);

          $( this ).css( "width", this.width + 'px' );
          this.id = "cart-image-" + this.id;

          if ( $('#piGalDiv_' + imgid).length ) {
            $(this).parent().colorbox({ inline: true, href: "#piGalDiv_" + imgid });
          }
        });
      }
    });
  });
  </script>

  <!-- jQuery Shopping Cart START -->
  <?php echo tep_draw_form( 'cart_quantity-options-' . $product_info['products_id'], tep_href_link( FILENAME_PRODUCT_INFO, tep_get_all_get_params( array( 'action' ) ) . 'action=add_product' ) ) . stripslashes( $product_info['products_description'] ); ?>

  <?php
    $products_attributes_query = tep_db_query( "select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'" );
    $products_attributes = tep_db_fetch_array( $products_attributes_query );
    if ( $products_attributes['total'] > 0 ) {
  ?>

      <p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>

      <p id="options-<?php echo (int)$product_info['products_id']; ?>">
  <!-- jQuery Shopping Cart END -->
  <?php
      $products_options_name_query = tep_db_query( "select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name" );
      while ( $products_options_name = tep_db_fetch_array( $products_options_name_query ) ) {
        $products_options_array = array();
        $products_options_query = tep_db_query( "select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'" );
        while ( $products_options = tep_db_fetch_array( $products_options_query ) ) {
          $products_options_array[] = array( 'id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name'] );
          if ( $products_options['options_values_price'] != '0' ) {
            $products_options_array[sizeof( $products_options_array )-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price( $products_options['options_values_price'], tep_get_tax_rate( $product_info['products_tax_class_id'] ) ) .') ';
          }
        }

        if ( is_string( $HTTP_GET_VARS['products_id'] ) && isset( $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']] ) ) {
          $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
        } else {
          $selected_attribute = false;
        }
  ?>
        <strong><?php echo $products_options_name['products_options_name'] . ':'; ?></strong><br /><?php echo tep_draw_pull_down_menu( 'id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute ); ?><br />
  <?php
      }
  ?>
      </p>

  <?php
    }
  ?>

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

  <?php
    if ( $product_info['products_date_available'] > date( 'Y-m-d H:i:s' ) ) {
  ?>

      <p style="text-align: center;"><?php echo sprintf( TEXT_DATE_AVAILABLE, tep_date_long( $product_info['products_date_available'] ) ); ?></p>

  <?php
    }
  ?>

    </div>

  <?php
    $reviews_query = tep_db_query( "select count(*) as count from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and reviews_status = 1" );
    $reviews = tep_db_fetch_array( $reviews_query );
  ?>

    <div class="buttonSet">
      <!-- jQuery Shopping Cart START -->
      <span class="buttonAction_oscart" data-id="options-" id="<?php echo (int)$product_info['products_id']; ?>"><?php echo '<h5 id="pi-product-info-'. (int)$product_info['products_id'].'" style="display:none"><a href="' . tep_href_link( FILENAME_PRODUCT_INFO, tep_get_all_get_params( array( 'action' ) ) . 'products_id=' . (int)$product_info['products_id'] ) . '" title="' . $product_info['products_name'] . '">' . $product_info['products_name'] . '</a></h5>' . tep_draw_hidden_field( 'products_id', $product_info['products_id'] ) . tep_draw_button( IMAGE_BUTTON_IN_CART, 'cart', null, 'primary' ) . '</form>'; ?></span>
      <!-- jQuery Shopping Cart END -->

      <?php echo tep_draw_button( IMAGE_BUTTON_REVIEWS . ( ( $reviews['count'] > 0 ) ? ' (' . $reviews['count'] . ')' : '' ), 'comment', tep_href_link( FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params() ) ); ?>
    </div>

  <?php
    if ( ( USE_CACHE == 'true' ) && empty( $SID ) ) {
      echo tep_cache_also_purchased( 3600 );
    } else {
      include DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS;
    }
  ?>

  </div>

  <?php
  }

  require DIR_WS_INCLUDES . 'template_bottom.php';
  require DIR_WS_INCLUDES . 'application_bottom.php';

Edited by Dr. Rolex

Share this post


Link to post
Share on other sites

Tks a lot for replying, Doc! :)

 

I'll try this on product_info.php to see if it corrects the image issue on v2.3.4

 

But as for the other files, those were the ones I was using. Problem seems to be on bm_shopping_cart.php, for when I remove it, layout goes back to normal on IE9. I think it's probably something small like a coma misplaced that throws a javascript error on IE9. I already googled those errors but since I'm not a programmer, I can't find something that can fix these errors.

 

Would it be too much to ask you to take a deeper look whenever you find some spare time? This is one of the best contributions ever and I'd really love to use it on my client's store.

 

Tks a lot for your help! :)


Patty

Share this post


Link to post
Share on other sites

Tks a lot for replying, Doc! :)

 

I'll try this on product_info.php to see if it corrects the image issue on v2.3.4

 

But as for the other files, those were the ones I was using. Problem seems to be on bm_shopping_cart.php, for when I remove it, layout goes back to normal on IE9. I think it's probably something small like a coma misplaced that throws a javascript error on IE9. I already googled those errors but since I'm not a programmer, I can't find something that can fix these errors.

 

Would it be too much to ask you to take a deeper look whenever you find some spare time? This is one of the best contributions ever and I'd really love to use it on my client's store.

 

Tks a lot for your help! :)

 

Can you post a screenshot of the problem? Or can you send a link to the shop you're trying to fix? Send it via PM if you don't want to post it here.

 

Is this problem only occurring on IE9?

Share this post


Link to post
Share on other sites

I'll install it again on the online testing site and will post a link for you to check it.

And yes, the layout issue due to the javascript errors is happening only on IE9.

 

Tks a lot, Doc! :)

Edited by Patty

Patty

Share this post


Link to post
Share on other sites

I think the problem with file includes/modules/boxes/bm_shopping_cart.php is that it is quite different on version 2.3.4 and maybe that's why it's throwing errors on IE.

Do you think you could find some time to update this file to be compatible with the new version 2.3.4?

 

I didn't check the optional files but it's quite possible that they need to be updated as well. Version 2.3.4 introduced new features that make it very different from older versions.

 

Tks a lot for your help, Doc!


Patty

Share this post


Link to post
Share on other sites

I think the problem with file includes/modules/boxes/bm_shopping_cart.php is that it is quite different on version 2.3.4 and maybe that's why it's throwing errors on IE.

Do you think you could find some time to update this file to be compatible with the new version 2.3.4?

 

I didn't check the optional files but it's quite possible that they need to be updated as well. Version 2.3.4 introduced new features that make it very different from older versions.

 

Tks a lot for your help, Doc!

 

No, the errors you're getting in IE console (as well as all the other browser consoles) are javascript warnings & errors.

IE is a mess, you usually have to introduce "hacks" and other shitty code since IE simply doesn't work in many ways.. Especially the older versions..

 

To try to solve this I would start with switching the jquery (not jquery-ui) versions. The easiest way to do this is to use Google's Hosted Libraries instead of using local versions of them.

In includes/template_top.php find these two lines (they might differ a bit)

<script type="text/javascript" src="ext/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="ext/jquery/ui/jquery-ui-1.10.4.min.js"></script>

Replace with

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>

Take a look at Google's Hosted Libraries by clicking here. You will see which versions they have of both jquery and jquery-ui, now try to lower the jquery version by simply changing the numbers in the code you just replaced and see if it makes any difference.

 

In IE console, look at which files that the errors are coming from, this error for example:

 

 

Error Message: Object doesn't support property or method 'getAttribute'

 

Isn't used in jquery-oscart.js, so you should be able to expand on the error and you'll probably find that it's jquery.js that's causing it.

 

To get rid of this message

 

 

Also I get the following errors:

Line: 24

Character: 2

Code: 0

Error Message: 'IMAGE_BUTTON_DELETE' is undefined

URL: http://localhost/MyWebs/catalog/ext/modules/shopping_cart/jquery-oscart.js?1200

 

 

Add this definition to ./includes/languages/english.php (and other languages like portuguese.php)

define('IMAGE_BUTTON_DELETE', 'Delete');

Make sure first that everything works under Firefox and Chrome, after that proceed to the shitty one (IE) and if you can't solve it, reply with what error messages you get and if possible expand them to see the full stack trace.

Share this post


Link to post
Share on other sites

Tks once again for your time and efforts, Doc. ;)

 

I have tried the Google's Hosted Libraries already, the errors persisted.

I'll try once again reinstalling from scratch with your hints and let's see what happens.

Will let you know.


Patty

Share this post


Link to post
Share on other sites

@@Dr. Rolex

 

I've installed this mod onto a clean oscommerce 2.3.4 install and everything works well, I've checked with IE 11, Chrome, Safari, Opera and Firefox and all seems fine - I'm not really bothered with IE and below.

 

But I am finding it quite taxing add the code to the modules.   Please could you have a look at this code and give me advice on how and where to add your code, I'm really struggling with this :( I'd really appreciate this very much

<?php
/*
 * $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License
 */
if ((! isset ( $new_products_category_id )) || ($new_products_category_id == '0')) {
	$new_products_query = tep_db_query ( "select p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_featured = '1' and p.products_id = pd.products_id and pd.language_id = '" . ( int ) $languages_id . "' order by RAND() limit " . MAX_DISPLAY_NEW_PRODUCTS );
} else {
	$new_products_query = tep_db_query ( "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . ( int ) $new_products_category_id . "' and p.products_status = '1' and p.products_featured = '1' and p.products_id = pd.products_id and pd.language_id = '" . ( int ) $languages_id . "' order by RAND() limit " . MAX_DISPLAY_NEW_PRODUCTS );
}
$num_new_products = tep_db_num_rows ( $new_products_query );
if ($num_new_products > 0) {
	$counter = 0;
	$col = 0;
	$new_prods_content = '<div class="grid-100 grid-parent">';
	while ( $new_products = tep_db_fetch_array ( $new_products_query ) ) {
		$counter ++;
		if ($col === 0) {
			$new_prods_content .= '<div class="grid-33 mobile-grid-100 tablet-grid-33">';
		}
		$new_prods_content .= '<div class="border grid-100 mobile-grid-100">
<div class="grid-100 mobile-grid-100" style="text-align:center">
  <div class="product_name box mobile-grid-100">
    <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id'] ) . '">' . $new_products['products_name'] . '</a>
  </div>
  <div class="product_img box mobile-grid-100">
    ' . tep_image_cdn(DIR_WS_IMAGES_CDN . $new_products ['products_image'], $new_products['products_name'],SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
  </div>
</div>
<div class="grid-100 mobile-grid-100 tablet-grid-100">
  <div class="product_price box grid-50 mobile-grid-100 tablet-grid-50">
    <div class="prodprice mobile-grid-100 tablet-grid-50">
      ' . $currencies->display_price ( $new_products['products_price'], tep_get_tax_rate ( $new_products['products_tax_class_id'] ) ) . '
    </div>
  </div>
  <div class="product_more_info box grid-50 mobile-grid-100 tablet-grid-50">
    <div class="moreinfo mobile-grid-100 tablet-grid-50">
      <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id'] ) . '">' . READ_MORE . '</a>
    </div>
  </div>
</div>
</div>';
		$col ++;
		if (($col > 0) || ($counter == $num_new_products)) {
			$new_prods_content .= '</div>';
			$col = 0;
		}
	}
	$new_prods_content .= '</div>';
?>
<div class="contentText">
  <?php echo $new_prods_content; ?>
</div>
<?php
}
?>


"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

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

×