Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Show sold out products, yes-no drop down


ianric

Recommended Posts

Hi

 

I've installed one of the sold out contribs and modified my site so that sold out products are displayed but can't be added to the cart, there is a "notify me" button instead.

 

What I'd like to add is the option for the customer to choose whether or not to show sold out via a drop down box.

 

I don't know where to start so please could someone point me in the right direction

 

Many thanks

 

Ian

Link to comment
Share on other sites

Hey Ian,

 

I'm not good enough with PHP to help you with that, but...

 

From a merchants point-of-view that's not really a good idea.

 

I often have products that are not available for a few weeks until my supplier gets more in.

 

I have had (and still have) customers actually use the product notifications so they can complete their purchase when I get the product back in stock.

 

If those customers chose not to see the "sold out" or "On Backorder" products I would have lost quite a few sales.

 

Just something to think about. wink.gif

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

  • 1 year later...

Hi Jim & everyone

 

Thanks for the reply and sorry for the looonnnnnnngggggg waiiiiiittttt. I understand your point but I've found it useful so just revisiting now that I know a bit more about Osc and PHP but I'm stuck again. See it working at juno.co.uk. Search for an artist and look at the top left. There's 2 drop downs. htfr.com has something similar.

 

 

So... By default, only products in stock are displayed. A "quick" code edit or a sold out contrib (which I have but isn't live yet) can show them all.

 

In product listing, I'd like a drop down Yes/No box that says "display out of stock items" "yes/no" with No being the default and Yes shows all stock

 

Was going to post in the How to create a drop down in Tips and tricks section. Anyway, I sort of understand the first 2 posts from that thread but had to change table names and fields then got stuck on the href links.php. Tried to change it to tep_href_link(basename($PHP_SELF) but kept getting a forbidden error.

 

I do have Sams Product Listing Enhancements, Thumbnails & Manufacturer Headings installed and I've copied the "Results per page" dropdown which sort of works. I *think* I'm 3/4 there.

 

I'm stuck with "how do you tell the product listing page what to display?" This is what I have

 

At the top of product_listing I originally had copied the listing_sql from index.php and made it an if - seems logical to me. Tried !=, ==1, !=1 etc. I now know this is WRONG

if($_GET['yesno'] == 0){;
$listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_quantity, p.products_status, p.products_id, p.products_quickfind, p.products_category, p.manufacturers_id, m.manufacturers_name, p.products_price, p.products_media, p.products_label, p.products_catno, p.products_model, 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, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status='1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

} else {
$listing_sql = "select " . $select_column_list . " p.products_date_added, p.products_quantity, p.products_status, p.products_id, p.products_quickfind, p.products_category, p.manufacturers_id, m.manufacturers_name, p.products_price, p.products_media, p.products_label, p.products_catno, p.products_model, 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, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where  p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

}

Above the "Results per page" dropdown, I have

 

$select_array[] = array('id' => '0', 'text' => 'No Change');
$select_array[] = array('id' => '1', 'text' => 'Yes');

 

Then underneath the "Results per page" dropdown, I have modded Sams code. Maybe I need to remove the form elements

 

$yes_no =  '<br /><table width="100%" cellspacing="0" cellpadding="2"><tr><td class="smallText">Yes/No: '. tep_draw_form('yesno', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get') . $get_vars . (isset($_GET['yesno']) ? tep_draw_hidden_field('yesno', $_GET['yesno']) : '') . tep_draw_pull_down_menu('yesno', $select_array, $_GET['yesno'], 'onChange="this.form.submit();"') . tep_hide_session_id().'</form></td></tr></table>';

and an echo $yes_no;

 

I have the drop down, the page does refresh and my variable "yesno=0" shows in the URL and I get all stock listed I now realise this is WRONG. The $listing at the top overode the main $listing

but the next time I select an option, I get a second "yesno=" variable and a third like this

 

localhost/index.php?cPath=145&yesno=0&yesno=0&yesno=1&osCsid=rp0v4p5d0qa71imnog7h07p403

 

Sorry for the long post and like I said I *think* I'm 3/4 there.

 

Please could someone help me out on the last bit

 

 

Cheers

 

Ian

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...