0
votes

Im still a newbie learning things day by day. I have posted my question at the OpenCart forum website looking for help and now here in StackOverflow. I need your help guys.

Hi there, Im a newbie getting used to Opencart environment. I need help with product bands as I have attached in picture below. I need the coming_soon option to overwrite the out_of_stock option settings. Its not working correctly as Im confused with the logic that has been made. Out_of_stock option works when there is only "0" quantity products. When we have a new product that is Coming_soon we would make that product quantity "0" as well but something is wrong here and the Coming_soon is not overwriting the Out_of_stock setting. I need some help here.

Coming_soon checkbox

Product quantity

Out of stock band

Coming Soon band

catalog/controller/product/category.php

/*OOS Band start*/
            $optionsQty = 0;
            $oosQty = 0;
            foreach ($this->model_catalog_product->getProductOptions($result['product_id']) as $option) {
                if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox' || $option['type'] == 'image') {
                    foreach ($option['option_value'] as $option_value) {
                        $optionsQty++;
                        if ($option_value['quantity'] <=0) $oosQty++; 
                    }
                }
            }
            if ($optionsQty == $oosQty && $optionsQty > 0 ) {
            $band_oos = true;
            }
            else $band_oos = false;          /*OOS Band end*/

catalog/view/product/category.tpl

 <div class="for_infine">
                                <?php if ($product['band_oos']) { ?>
                                    <span class="band-oos">&nbsp;</span>
                                <?php } ?>
                                <?php if ($product['band_free_shipping'] == 'Yes') { ?>
                                    <span class="band-free-shipping">&nbsp;</span>
                                <?php } ?>

                                <?php if ($product['band_new'] == 'Yes') { ?>
                                    <span class="band-new">&nbsp;</span>
                                <?php } ?>

                                <?php if ($product['band_coming_soon'] == 'Yes') { ?>
                                    <span class="band-coming-soon">&nbsp;</span>
                                <?php } ?>
                                <br />

catalog/controller/product/product.php

$this->data['options'] = array();

            $optionsQty = 0;
            $oosQty = 0;
            foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { 
                if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox' || $option['type'] == 'image') { 
                    $option_value_data = array();

                    foreach ($option['option_value'] as $option_value) {
                        $optionsQty++;
                        if ($option_value['quantity'] <=0) $oosQty++; 

                        if ((float)$product_info['special']) {
                            $price_original = $product_info['special'];
                        }else {
                            $price_original = $product_info['price'];

                        }

catalog/view/product/product.tpl

<div class="left">
            <div class="heading" style="line-height: 27px; font-size: 25px;"><?php echo $heading_title; ?></div>
                <?php if ($thumb) { ?>
                <div class="image">


              <?php if ($band_oos ) { ?>
                <div class="oos_tab_large top-right-cnr"></div>
              <?php } ?>
                    <?php if ($band_free_shipping == 'Yes') { ?>
                          <div class="free_shipping_tab_large top-right-cnr"></div>
                      <?php } ?>
                    <?php if ($band_new == 'Yes') { ?>
                          <div class="new_tab_large top-right-cnr"></div>
                       <?php } ?>
              <?php if ($band_coming_soon == 'Yes') { ?>
              <div class="coming_soon_tab_large top-right-cnr"></div>
              <?php } ?>
1
Please post your question here instead of linking to an off-site one.jsheeran
sorry @jsheeran, I was even new to stackoverflow but now i manage to post it with the help of my friend.user8530557

1 Answers

0
votes

Opencart out of stock warning can be disabled in settings:

Settings -> Your Store -> Edit -> Options -> Show Out Of Stock Warning

If you need both Stock Warning and Bands to work together you need to rethink new products adding with 0 quantity.