![]() |
It is possible? hoping that someone can help me
http://i91.photobucket.com/albums/k293/pindeho2005/howagain.gif
it is possible if i hit the Size 3.5 x 4 folded business card my quantity box will automatically change it to 1000? thanks |
Re: It is possible? hoping that someone can help me
You will probably need to have this custom coded.
|
Re: It is possible? hoping that someone can help me
I dont know how to code :( can anyone help me how? pls
|
Re: It is possible? hoping that someone can help me
That's what I mean, you'll need to hire someone to do this for you.
|
Re: It is possible? hoping that someone can help me
Quote:
Hi. Your post reminded to look into this - although you do have the ability to write some custom javascript for a given product option group via the product admin tools, the code you write is only executed when one actually submits the form to add the product to one's cart. What would be more useful - such as in your case - is to be able to add some custom javascript that is executed by the onchange() event. This is what the stock x-cart does, actually - it calls a function called check_options(). In any case, I'm nearly done with a mod that allows you to add some custom javascript that gets called by check_options(). I just added a textarea for that code beneath the existing one on the product options admin page and added a field to the product_options_js db table to store it. It's functional now, I just need to write up the steps and will try to get that posted tonight. I had to modify a bit more than I would have liked, but I'll go ahead and post what I've got asap. Nate |
Re: It is possible? hoping that someone can help me
ok thank i will wait for that..
|
Re: It is possible? hoping that someone can help me
Hi again,
Well, here is what I have so far. I'm still considering what else might be useful along these lines, perhaps exending it to handle other events, but for now hopefully it will be of use to some folks out there. NOTE: This has been tested only on X-Cart 4.1.9 Step 1: Alteration to DB; we need a field to store our javascript code. Use your preferred mysql client to execute the following SQL: Code:
ALTER TABLE xcart_product_options_js ADD custom_javascript_code TEXT; Step 2: Modify the following PHP files: a) $xcart_dir/modules/Product_Options/product_options.php after :: Code:
# change the two lines in the subsequent code that begin with 'func_array2insert' such that our new js code will be properly stored in the db :: Code:
/* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === */ then, directly after :: Code:
# Get the product options list add the following line that retrieves our custom javascript from the db for a given product and stores it in the variable '$custom_product_options_js' :: Code:
/* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === */ then directly after the following :: Code:
if (!empty($product_options_js)) add the following to pass that variable off to our smarty object :: Code:
/* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === */ b) $xcart_dir/modules/Product_Options/func.php after :: Code:
# add the following :: Code:
/* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === */ c) $xcart_dir/modules/Product_Options/customer_options.php after :: Code:
$product_options = func_get_product_classes($productid, !empty($product_info['is_taxes'])); add the following :: Code:
/* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === */ then, after :: Code:
$smarty->assign("err", $err); add the following :: Code:
/* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === */ Step 3: Modify and/or create the following Smarty templates: a) Create the file $xcart_dir/skin1/modules/Product_Options/custom_check_options_js.tpl :: Code:
{* $Id: custom_check_options_js.tpl,v 1.0.0 2007/12/28 04:14:37 nth Exp $ *} b) $xcart_dir/skin1/modules/Product_Options/product_options.tpl after :: Code:
<table cellspacing="0" cellpadding="0" width="100%"> add the following :: Code:
{* === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === *} c) $xcart_dir/skin1/customer/main/product.tpl near the top of the file, directly after :: Code:
{include file="form_validation_js.tpl"} add the following :: Code:
{* ==== BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === *} Step 4: Modify the following Javascript file: a) $xcart_dir/skin1/modules/Product_Options/func.js after :: Code:
/* add the following :: Code:
// === BEGIN NTH PRODUCT OPTS JAVASCRIPT MOD === Step 5: Add the following language variable - 'txt_custom_product_options_js_note' with the value: Code:
Below you can write a client-side Javascript code that will be launched when a customer decides to add a product to cart and starts selecting options with which the product should be added. This script will execute when any options' onchange() event handler is triggered, rather than when the onsubmit() handler is triggered, as with the custom javascript textarea above. You need to have skills in Javascript programming to avoid errors on the customer frontend. Usage: When administering a given product's options, you'll now find an additional textarea directly underneath the one used for custom form validation code on the customer front-end product detail page. The same notes apply - you need some familiarity with javascript to do anything useful, etc... The code gets executed by the same function that the stock x-cart code uses to handle various tasks when a product options' onchange() event is triggered, i.e. check_options(). a simple example (completely contrived - your code will need to refer to your specific product option variables, etc.): Code:
var optid = document.getElementById('po3'); I hope this is useful to someone, and suggestions/improvements are most welcome. Regards, Nate |
Re: It is possible? hoping that someone can help me
One more thing,
I did not include the code needed to include the custom javascript code in the import/export admin procedures. If there is interest, or as time permits, I'll add that and then perhaps post it to 'completed mods'. Meanwhile. let me know if there's any particular feature someone needs and I'll see if I can help. Nate |
Re: It is possible? hoping that someone can help me
by the looks of the screen shot, you are using product.tpl...just put a if statement and in a javascript put
Code:
var selitem = document.getElementById('po'+whatevertheidforthe3.5x4selectboxis).value; as for the product options javascript mod, just an idea, it may be easier to just modify the form validation and putting it as an onchange to the select input...should require less modification and support importing/exporting the javascript |
Re: It is possible? hoping that someone can help me
Quote:
Good point, but if I understand you correctly you'd (at least for the specific product in question) have to choose one or the other (onsubmit or onchange), but not both. Please let me know if that's not the case. As I mentioned, this mod did require a good bit more changes to the code than I would have liked, but I've got a number of scenarios that I need to handle where I'm going to need the flexibility it offers, and I didn't want to have to special case the form validation every time. In particular, I'm writing a Smarty plugin that hooks into the HTML_AJAX PEAR module (which I am a big fan of) and I'm experimenting a bit using the product options JS mod and the Extra Fields HTML mod that someone else contributed, which opens up a lot of possibilities, but quickly leads to the maintainability issues inherent in most (all?) template-based systems. As much as I enjoy working with X-Cart, as others have pointed out there is one problem with mod development in particular that really needs to be addressed - the inability to produce a workable patch system for the Smarty templates. We simply have to use the de facto documentation style that amounts to writing a diff by hand - I'm not knocking it, really, it's quite usable, but time-consuming and error-prone no matter how careful one tries to be. I've seen a couple of posts lately that touch on it, and if there are any others willing to try to come up with a usable system, I'm certainly willing to devote some time and effort to the project. Anyway, sorry to veer so far off course, but I finished the import/export part of the mod, which I've just successfully tested, so after checking it over one more time I'll amend the original product options mod post, so that should no longer be an issue. Thanks for your feedback, I really appreciate it. Regards, Nate |
All times are GMT -8. The time now is 12:06 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.