X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Customized Product Options (https://forum.x-cart.com/showthread.php?t=17540)

jtoth 10-26-2005 08:09 PM

Customized Product Options
 
I made this mod (v 4.0.16) as a client wanted only a few categories to have a certain type of option. The client also the options displayed as radio buttons with an image. I did not want to mod the Produce Options module directly as the cliented needed it for all other products. This mod does the trick if you don't mind the manual update. For those interested in having something like this integrated into the admin, it can be done as well with some extra work. (replace 'skin1' with your actual skin dir):

1. Create a new product, ensure it is disabled and label accordingly so you know this is your pseudo product. Next add options as you would a regular product, adding all the options you would like. Note the class ID number.

2. Access database directly or through phpMyAdmin. Browse the table x_cart_class_options and you will see all the options you created, associated with the class ID you noted from step #1. Copy down each optionid for this particular class. Next, browse the xcart_categories table and note each categoryid that you want this product option to show up in.

3. Lets create the .tpl for our new option look. Create a new file in /skin1/customer/ ... name it anything but ensure it has the .tpl extension. It should look like the following, replace 60 with your classID, each value with the optionID you got from the database, and replace images as necessary:

Code:

{* Custom Product Options *}
<tr>
  <td valign="middle">{$lng.lbl_custom_option}</td>
  <td>
    <table width="100%">
      <tr>
            <td align="center"><input type="radio" id="po60" name="product_options[60]" value="199" />
Gold
[img]/shop/images/ring_temp.jpg[/img]</td>
            <td align="center"><input type="radio" id="po60" name="product_options[60]" value="200" />
Bronze
[img]/shop/images/ring_temp.jpg[/img]</td>
            <td align="center"><input type="radio" id="po60" name="product_options[60]" value="201" />
Silver
[img]/shop/images/ring_temp.jpg[/img]</td>           
          </tr>
    </table>
  </td>
</tr>


** Also ensure you create a language variable for the label used above

4. We need to register the strstr() PHP function in /product.php so Smarty can access it in our .tpl file (someone please let me know if Smarty already has this functionality!)

Code:

# Add a custom function
$smarty->register_function('strstr', 'strstr');


5. Open /skin1/customer/main/product.tpl ... and include the file from Step 3 just as you would any other .tpl file. I placed mine as follows (you can put it anywhere), and it will only show for a category which is under one of my root categories (248):


Code:

<TR><TD class="Line" height="1" colspan="2">[img]{$ImagesDir}/spacer.gif[/img]</TD></TR>
<TR><TD colspan="2"></TD></TR>
{**** Custom Product Options ****}
{if strstr($current_category.categoryid_path, '248')}
{ include file=customer/loose_diamonds_settings.tpl"}
{/if}
{**** /Custom Product Options ****}

{if $active_modules.Product_Options ne ""}
{ include file="modules/Product_Options/customer_options.tpl"}
{/if}


I hope this helps someone ...

junaid 12-05-2005 09:17 AM

thanks would give it a try.
much needed.
regards
Junaid

xgarb 12-07-2005 06:11 AM

Cool, thanks for that...

I used a variation of your technique to get a hidden form field added to the product when it was added to the cart.

xgarb

simco 06-07-2006 07:52 PM

I'd love to have this mod if it used checkboxes instead of radio buttons. Any chance of getting it changed to do so? I have an extreme need to list literally dozens of options for musical instruments and allow the customer to select multiple ones. The radio button is for either/or. I need a mod to allow 'and, and, and...'


All times are GMT -8. The time now is 04:34 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.