X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Product Options Customizaion ? (https://forum.x-cart.com/showthread.php?t=33019)

RichieRich 09-09-2007 11:24 AM

Re: Product Options Customizaion ?
 
good job so far, its much clearer with radio buttons, the customer can see it on the page, instead of it being hidden in a drop down they have to click

inebriate 09-09-2007 02:20 PM

Re: Product Options Customizaion ?
 
use
Code:

{foreach from=$v.options item=o}
<input id="po{$v.classid}" type="radio" name="{$poname}" value="{$o.optionid}" {if $nojs ne 'Y'} onclick="javascript: check_options();"{/if}/>{$o.option_name}
<br />
{/foreach}


to include the javascript for updating the price and image and what not

hhiker 09-09-2007 02:42 PM

Re: Product Options Customizaion ?
 
Ok, I changed what I had which was:

Code:

{if $nojs ne 'Y'} onchange="javascript: check_options();"{/if}

to (the only difference in your code & mine)

Code:

{if $nojs ne 'Y'} onclick="javascript: check_options();"{/if}

and that did not work to update the prices, etc.

RichieRich 09-10-2007 01:05 AM

Re: Product Options Customizaion ?
 
that code didnt update the price

inebriate 09-10-2007 12:16 PM

Re: Product Options Customizaion ?
 
well i checked out the javascript file itself...it seems like using radio options will break a lot of the code, its not going to be as simple as a replace

the problem with using radio inputs is that now a group of options will all share the same id and name, so its going to require more manipulation with DOM or with the naming scheme of the inputs

hhiker 09-10-2007 12:31 PM

Re: Product Options Customizaion ?
 
I am good, I am not that good. Can you do it for us?! :lol:

inebriate 09-10-2007 04:38 PM

Re: Product Options Customizaion ?
 
when i have time i will have a crack at it

pyap 09-11-2007 11:34 AM

Re: Product Options Customizaion ?
 
This should be close to what you're looking for. I'm not sure if it works because I have my radio button id's modified. I edited this version to work with the default x-cart installation. At a minimum, this is a good place to start for others.

Change the SELECT elements to INPUT type RADIO as mentioned in previous posts. Then...

In skin1/modules/Product_Options/func.js

Change:

Code:

/*
        Get product option value
*/
function getPOValue(c) {
        if (!document.getElementById('po'+c) || document.getElementById('po'+c).tagName.toUpperCase() != 'SELECT')
                return false;
        return document.getElementById('po'+c).options[document.getElementById('po'+c).selectedIndex].value;
}


To:

Code:

/*
        Get product option value -modified
*/
function getPOValue(c) {
        if (!document.getElementsByName('product_options['+c+']'))
                return false;
        var radios = document.getElementsByName('product_options['+c+']');
        for (var i = 0; i < radios.length; i++) {
                if (radios[i].checked) {
                        return radios[i].value;       
                }
        }
}


Let me know how it goes.

-Scott

hhiker 09-11-2007 12:10 PM

Re: Product Options Customizaion ?
 
It works and it works beautifully! :D/

I never really dove into JavaScript after learning too many languages that I never have had a need for. I am getting ready to dive into JavaScript & Ajax as soon as I get time. I have determined I need to.

Thanks so much! That was a very simple fix for those who know JS. =D>

hhiker 09-11-2007 12:20 PM

Re: Product Options Customizaion ?
 
Just make sure you put the onclick instead of onchange like last shown in post #13 (thanks inebriate!) or it will not change everything until you click away from the radio button you just clicked.


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

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