Post by SamNabz » Tue Jun 12, 2012 11:44 am

Hi all,

I was just wondering what the best method for setting the subtract stock option to NO as default when adding a product. I would also like this field to be set to NO when adding options.

Running OC v1.5.1 - any info is appreciated.

Thank you.

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by dirtboy » Tue Jun 12, 2012 12:32 pm

here is a mod that will do it for you. not sure if it works on options though

http://www.opencart.com/index.php?route ... order=DESC

“Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.”
- Henry Ford


User avatar
Active Member

Posts

Joined
Wed Mar 07, 2012 3:04 pm

Post by SamNabz » Tue Jun 12, 2012 1:55 pm

Thanks for the quick reply dirtboy. However, I saw that mod earlier and it states it is for OC 1.5.2 and higher - I am using 1.5.1

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by dirtboy » Tue Jun 12, 2012 2:01 pm

then do it manually, find this file admin > controller > catalog > product.php

find this line of code around line 841

Code: Select all

$this->data['subtract'] = 1; 
change it to

Code: Select all

$this->data['subtract'] = 0; 

“Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.”
- Henry Ford


User avatar
Active Member

Posts

Joined
Wed Mar 07, 2012 3:04 pm

Post by SamNabz » Tue Jun 12, 2012 5:00 pm

Tried that, however there are a couple of issues...

1. the subtract stock field stays set to YES even though it saves as NO (not a big deal..)
2. if you add options to a product, the product subtract stock resets back to yes...

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by rupaknepali » Tue Jun 12, 2012 8:19 pm

As per my understanding to the question, i have written below:

Change to be done at admin/view/template/catalog/product_form.tpl
=====================
For subtract
Find below
=====================
<?php if ($subtract) { ?>
<option value="1" selected="selected"><?php echo $text_yes; ?></option>
<option value="0"><?php echo $text_no; ?></option>
<?php } else { ?>
===================================
Change to
===================================
<?php if ($subtract) { ?>
<option value="1"><?php echo $text_yes; ?></option>
<option value="0" selected="selected"><?php echo $text_no; ?></option>
<?php } else { ?>

=====================================
For options
on the same product_form.tpl
Find
=====================================
<?php if ($product_option_value['subtract']) { ?>
<option value="1" selected="selected"><?php echo $text_yes; ?></option>
<option value="0"><?php echo $text_no; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_yes; ?></option>
<option value="0" selected="selected"><?php echo $text_no; ?></option>
<?php } ?>
</select>
======================================
<?php if ($product_option_value['subtract']) { ?>
<option value="1" ><?php echo $text_yes; ?></option>
<option value="0" selected="selected"><?php echo $text_no; ?></option>
<?php } else { ?>
<option value="1"><?php echo $text_yes; ?></option>
<option value="0" selected="selected"><?php echo $text_no; ?></option>
<?php } ?>
</select>

======================================

Find

======================================

html += '<td class="left"><select name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][subtract]">';
html += ' <option value="1"><?php echo $text_yes; ?></option>';
html += ' <option value="0" ><?php echo $text_no; ?></option>';
html += ' </select></td>';
=====================================

Replace with

=====================================

html += '<td class="left"><select name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][subtract]">';
html += ' <option value="1"><?php echo $text_yes; ?></option>';
html += ' <option value="0" selected="selected" ><?php echo $text_no; ?></option>';
html += ' </select></td>';

Seem codes look long but change is small, i showed all the codes for better understanding, hope this will work out.

Visit http://rupaknepali.com.np for more logics :)

Rupak Nepali
webocreation.com@gmail.com
http://webocreation.com
Enjoy! Tips and tricks as well as free module.


Active Member

Posts

Joined
Mon Apr 25, 2011 7:04 pm

Post by SamNabz » Wed Jun 13, 2012 8:29 am

Thanks Rupak, worked perfectly!!

Cheers, Sam


Active Member

Posts

Joined
Wed Jul 06, 2011 7:32 am
Location - Sydney, Australia

Post by rph » Wed Jun 13, 2012 2:47 pm

Admin Enhancement Suite also allows you to set defaults for your products like subtract stock (both product and product options).

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by kotysoft » Thu Jun 14, 2012 5:31 pm

rupaknepali wrote:As per my understanding to the question, i have written below:

Change to be done at admin/view/template/catalog/product_form.tpl
=====================
For subtract
Find below
=====================

...

It's more safe and simplier (for option subtract) to change the direction...



Find
admin/view/template/catalog/product_form.tpl

Code: Select all

html += '<td class="left"><select name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][subtract]">';
html += ' <option value="1"><?php echo $text_yes; ?></option>';
html += ' <option value="0" ><?php echo $text_no; ?></option>';
html += ' </select></td>'
Modify

Code: Select all

Find

======================================

html += '<td class="left"><select name="product_option[' + option_row + '][product_option_value][' + option_value_row + '][subtract]">';
html += ' <option value="0" ><?php echo $text_no; ?></option>';
html += ' <option value="1"><?php echo $text_yes; ?></option>';
html += ' </select></td>'

New member

Posts

Joined
Sat Feb 06, 2010 10:01 pm

Post by WavMixer » Fri Jul 04, 2014 3:15 am

Thank you rupaknepali !!!!!

User avatar
New member

Posts

Joined
Sun Feb 23, 2014 3:15 am

Who is online

Users browsing this forum: No registered users and 99 guests