Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Specials Ribbon Overlay For OsCommerce 2.3.4/BS


Recommended Posts

  • Replies 54
  • Created
  • Last Reply
  • 5 months later...
On 21/06/2017 at 8:38 PM, Omar_one said:

@Jeep_ice
 sometime ago @burt share some code on the forum to do this . I don't know the topic, but here the copied code:

in /includes/functions/html_output.php
Find:
 


if ( isset($params['params']) ) {
      $button .= ' ' . $params['params'];
    }

add after it
 


 if (isset($params['product_id']) ) {
      $products_quantity_query = tep_db_query("select products_quantity from products where products_id = " . (int)$params['product_id']);
      $products_quantity = tep_db_fetch_array($products_quantity_query);
      if ($products_quantity['products_quantity'] < 1) {
        $button .= ' disabled="disabled" ';
        $title   = 'Out Of Stock';
        $icon    = 'fa fa-times-circle';
        $style   = 'btn-warning';
      }
    }   

in product_info.php
find this
 


tep_draw_button(IMAGE_BUTTON_IN_CART, 'fa fa-shopping-cart', null, 'primary', NULL, 'btn-success')

replace with this
 


tep_draw_button(IMAGE_BUTTON_IN_CART, 'fa fa-shopping-cart', null, 'primary', array('product_id' => $product_info['products_id']), 'btn-success')

Omar

Hi Omar,

just to give you a bit of feedback on the above changes affecting the product_info page and also your out of stock ribbon contribution, both work nicely and the changes above mean that the product_info page also reflect the out of stock status though not with the ribbon but that does not matter. The code in my Edge version was not quite as shown above and I had to change (around line 203)

<div class="col-xs-6 text-right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'fa fa-shopping-cart', null, 'primary', array('params' => 'data-has-attributes="' . (($products_attributes['total'] > 0) ? '1' : '0') . '" data-in-stock="' . (int)$product_info['products_quantity'] . '" data-product-id="' . (int)$product_info['products_id'] . '"'), 'btn-success btn-product-info btn-buy'); ?></div>

TO

<div class="col-xs-6 text-right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'fa fa-shopping-cart', null, 'primary', array('product_id' => $product_info['products_id']), 'btn-success'); ?></div>

and my original product_listing was (around line 169)

     if (PRODUCT_LIST_BUY_NOW > 0) {
        $prod_list_contents .= '       <div class="col-xs-6 text-right">';
        $prod_list_contents .=           tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . (int)$listing['products_id']), NULL, array('params' => 'data-has-attributes="' . ((tep_has_product_attributes((int)$listing['products_id']) === true) ? '1' : '0') . '" data-in-stock="' . (int)$listing['in_stock'] . '" data-product-id="' . (int)$listing['products_id'] . '"'), 'btn-success btn-product-listing btn-buy');
        $prod_list_contents .= '       </div>';
      }

and is now (as you advised)

         if ( tep_get_products_stock($listing['products_id']) > 0 ) {
        $prod_list_contents .= '       <div class="col-xs-6 text-right">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'fa fa-shopping-cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']), NULL, NULL, 'btn-success btn-sm') . '</div>';
    } else {
        $prod_list_contents .= '       <div class="ribbon red"><span> '. TABLE_HEADING_OUT_OF_STOCK . '</span></div>';
           }

great stuff Omar, many thanks.

 

5a30cd008caf5_Screenshotat2017-12-13063202.png.59f2beb72c96051fb7214e2ff9f801b4.png5a30cd01f1134_Screenshotat2017-12-13063130.png.2730027497c680733ac67560f4f6c80c.png5a30ccfeadfc6_Screenshotat2017-12-13063258.png.9063b569aa2e49fc3642dd23bf834a73.png

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...