Please help us to make AbanteCart Ideal Open Source Ecommerce Solution for everyone.

Support AbanteCart eCommerce

Author Topic: Grey out Product Options when out of stock  (Read 4867 times)

Offline www.PiShop.co.za

  • Newbie
  • *
  • Posts: 31
  • Karma: +7/-0
    • View Profile
Grey out Product Options when out of stock
« on: April 28, 2016, 11:22:56 AM »
On the default_html5 template (perhaps others too) the product options show the number left in stock or "Out of Stock" if applicable.
I'd like to disable (grey out) the radio button (or checkbox) when items are out of stock.

I had a look at the /storefront/view/default_html5/template/pages/product/product.tpl but I see the code for adding the options is pulling data from an Array (as seen below)                                     
Code: [Select]
<div class="controls">
<?php echo $option['html']; ?>
</div>

I have managed to get the item to disappear altogether by modifying the controller at /storefront/controller/pages/product/product/php but thats not what I'm looking for... Id really just like a way to have the radio button not selectable (but still visible) so:
Code: [Select]
<input id="option4131085" type="radio" value="1085" name="option[413][]" disabled>Black Modular R34.00 Out Of Stock rather than
Code: [Select]
<input id="option4131085" type="radio" value="1085" name="option[413][]" >Black Modular R34.00 Out Of Stock
Any help will be appreciated

Offline eCommerce Core

  • Administrator
  • Hero Member
  • *****
  • Posts: 1602
  • Karma: +93/-1
    • View Profile
Re: Grey out Product Options when out of stock
« Reply #1 on: May 02, 2016, 12:46:06 PM »
Based on your file path, you are looking at very old version of AbanteCart (prior to 1.2).

Anyways, the solution might be similar:

Quote
                           <?php if ($options) { ?>
                              <?php foreach ($options as $option) { ?>
                                 <div class="form-group">
                                    <?php if (!in_array($option['html']->type, array('hidden'))) { ?>
                                    <label class="control-label"><?php echo $option['name']; ?></label>
                                    <?php } ?>
                                    <div class="input-group col-sm-10">
                                       <?php echo $option['html'];   ?>
                                    </div>
                                 </div>
                              <?php } ?>
                           <?php } ?>
 

$option['html'] shows element ready HTML in echo, but it is actually an object of HtmlElementFactory.
You can use methods in the object to get option details and build your own custom HTML for your element.
 
Ultimately, you can edit HTML template for given HTML element located in folder /storefront/view/default/template/form/*

Look into core/engine/html.php

“If you’re in the luckiest one per cent of humanity, you owe it to the rest of humanity to think about the other 99 per cent.”
― Warren Buffett

Offline www.PiShop.co.za

  • Newbie
  • *
  • Posts: 31
  • Karma: +7/-0
    • View Profile
Re: Grey out Product Options when out of stock
« Reply #2 on: May 03, 2016, 03:25:45 AM »
Hi,

Nope Im running v1.2.6 (but i did start on v1.1.9 and have upgraded along with the releases but haven't switched templates yet)

Ill give it a try and report back.

 

Powered by SMFPacks Social Login Mod