Post by annelim » Sat Aug 18, 2012 2:55 pm

Dear all,

does any one know how to change the below code from checkbox into select dropbox like manufacturer ?
please help. why i need to change because the category all the way down and sometime the product was miss check into 2 different category. to avoid it i found below code. i had try to change it into select but it was not work when i click select it doesn't save into the category. this is original code.


<tr>
<td><?php echo $entry_category; ?></td>
<td><div class="scrollbox">
<?php $class = 'odd'; ?>
<?php foreach ($categories as $category) { ?>
<?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
<div class="<?php echo $class; ?>">
<?php if (in_array($category['category_id'], $product_category)) { ?>
<input type="checkbox" name="product_category[]" value="<?php echo $category['category_id']; ?>" checked="checked" />
<?php echo $category['name']; ?>
<?php } else { ?>
<input type="checkbox" name="product_category[]" value="<?php echo $category['category_id']; ?>" />
<?php echo $category['name']; ?>
<?php } ?>
</div>
<?php } ?>
</div>
<a onclick="$(this).parent().find(':checkbox').attr('checked', true);"><?php echo $text_select_all; ?></a> / <a onclick="$(this).parent().find(':checkbox').attr('checked', false);"><?php echo $text_unselect_all; ?></a></td>
</tr>
Last edited by annelim on Sat Aug 25, 2012 1:52 am, edited 1 time in total.

Active Member

Posts

Joined
Fri Oct 28, 2011 5:13 pm

User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)

Post by annelim » Mon Aug 20, 2012 3:29 pm

Image

here are the example result for the product category checkbox change to dropbox.

appreciate your help

Active Member

Posts

Joined
Fri Oct 28, 2011 5:13 pm

Post by Jeremy Fisk » Tue Aug 21, 2012 3:34 am

Yes that is possible, but please note that if you set it to a drop down box it means that you will only be able to select one category and not put the product in multipul categories...

Cheers

Jem

Hand Dryers

Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover


User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)

Post by annelim » Tue Aug 21, 2012 10:22 am

yes jem,

i just want to set to one category only instead of multiple category select ...version 1.5.3.1

Active Member

Posts

Joined
Fri Oct 28, 2011 5:13 pm

Post by Jeremy Fisk » Wed Aug 22, 2012 8:00 am

OK... try this...

change this:

Code: Select all

            <tr>
              <td><?php echo $entry_category; ?></td>
              <td><div class="scrollbox">
                  <?php $class = 'odd'; ?>
                  <?php foreach ($categories as $category) { ?>
                  <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                  <div class="<?php echo $class; ?>">
                    <?php if (in_array($category['category_id'], $product_category)) { ?>
                    <input type="checkbox" name="product_category[]" value="<?php echo $category['category_id']; ?>" checked="checked" />
                    <?php echo $category['name']; ?>
                    <?php } else { ?>
                    <input type="checkbox" name="product_category[]" value="<?php echo $category['category_id']; ?>" />
                    <?php echo $category['name']; ?>
                    <?php } ?>
                  </div>
                  <?php } ?>
                </div>
                <a onclick="$(this).parent().find(':checkbox').attr('checked', true);"><?php echo $text_select_all; ?></a> / <a onclick="$(this).parent().find(':checkbox').attr('checked', false);"><?php echo $text_unselect_all; ?></a></td>
            </tr>
To this:

Code: Select all

            <tr>
              <td><?php echo $entry_category; ?></td>
              <td><select name="product_category">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                   <?php foreach ($categories as $category) { ?>
                  <?php if (($category['category_id'] == $product_category) { ?>
                  <option value=<?php echo $category['category_id']; ?>" selected="selected"><?php echo $category['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
            </tr>
Note that i haven't tried it so not sure if it will work

Cheers

Jem

Hand Dryers

Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover


User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)

Post by annelim » Wed Aug 22, 2012 4:14 pm

hi jem,

it work only with show dropdown box but it didnt save the category into product.
do we need modify the controller/catalog/product.php as well ?

Active Member

Posts

Joined
Fri Oct 28, 2011 5:13 pm

Post by Jeremy Fisk » Fri Aug 24, 2012 11:03 am

annelim wrote:hi jem,

it work only with show dropdown box but it didnt save the category into product.
do we need modify the controller/catalog/product.php as well ?
Ok... im quite busy... i'll have a look early next week and maybe make a vqmod to do this

Cheers

jem

Hand Dryers

Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover


User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)

Post by Jeremy Fisk » Fri Aug 24, 2012 11:24 am

My error,

I dont have time to make a vqmod... but try this...

Change this:

Code: Select all

            <tr>
              <td><?php echo $entry_category; ?></td>
              <td><div class="scrollbox">
                  <?php $class = 'odd'; ?>
                  <?php foreach ($categories as $category) { ?>
                  <?php $class = ($class == 'even' ? 'odd' : 'even'); ?>
                  <div class="<?php echo $class; ?>">
                    <?php if (in_array($category['category_id'], $product_category)) { ?>
                    <input type="checkbox" name="product_category[]" value="<?php echo $category['category_id']; ?>" checked="checked" />
                    <?php echo $category['name']; ?>
                    <?php } else { ?>
                    <input type="checkbox" name="product_category[]" value="<?php echo $category['category_id']; ?>" />
                    <?php echo $category['name']; ?>
                    <?php } ?>
                  </div>
                  <?php } ?>
                </div>
                <a onclick="$(this).parent().find(':checkbox').attr('checked', true);"><?php echo $text_select_all; ?></a> / <a onclick="$(this).parent().find(':checkbox').attr('checked', false);"><?php echo $text_unselect_all; ?></a></td>
            </tr>
To this:

Code: Select all

			<tr>
              <td><?php echo $entry_category; ?></td>
              <td><select name="product_category[]">
                  <option value="0" selected="selected"><?php echo $text_none; ?></option>
                  <?php foreach ($categories as $category) { ?>
                  <?php if (in_array($category['category_id'], $product_category)) { ?>
                  <option value=<?php echo $category['category_id']; ?>" selected="selected"><?php echo $category['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $category['category_id']; ?>"><?php echo $category['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
            </tr>
Cheers and good luck

Jem

Hand Dryers

Bookstore Mod
QuickShop Module
Restricted Access - Compulsory Login
Template Override - Category Specific (vQmod)
Template Override - Brand Specific (vQmod)
How did you find out about us register question mod
Compulsory Login vQmod
Brands In Top Menu
zoom - Product Image - Auto on hover


User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)

Post by annelim » Sat Aug 25, 2012 2:01 am

THANK YOU jem, finally it work. five star for you

Active Member

Posts

Joined
Fri Oct 28, 2011 5:13 pm

User avatar
Active Member

Posts

Joined
Thu Nov 11, 2010 6:11 pm
Location - New Zealand (Tokomaru, Palmerston North)
Who is online

Users browsing this forum: No registered users and 78 guests