| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
It is possible? hoping that someone can help me | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() 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
__________________
Version 4.1.9 |
|||||||
#2
|
|||||||
|
|||||||
![]() You will probably need to have this custom coded.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#3
|
|||||||
|
|||||||
![]() I dont know how to code
![]()
__________________
Version 4.1.9 |
|||||||
#4
|
|||||||
|
|||||||
![]() That's what I mean, you'll need to hire someone to do this for you.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#5
|
|||||||
|
|||||||
![]() 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
__________________
-- Nathan T. Harper Nth Degree Consulting Web Dev / E-Commerce / ID Management X-Cart v4.1.9 + SpecialOffers + Magnifier + GiftReg + Survey + Custom tweaks FreeBSD + Apache 2.2.6 + PHP 5.2.3 + MySQL 5.0.24 |
|||||||
#6
|
|||||||
|
|||||||
![]() ok thank i will wait for that..
__________________
Version 4.1.9 |
|||||||
#7
|
|||||||
|
|||||||
![]() 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:
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:
then, directly after :: Code:
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:
then directly after the following :: Code:
add the following to pass that variable off to our smarty object :: Code:
b) $xcart_dir/modules/Product_Options/func.php after :: Code:
add the following :: Code:
c) $xcart_dir/modules/Product_Options/customer_options.php after :: Code:
add the following :: Code:
then, after :: Code:
add the following :: Code:
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:
b) $xcart_dir/skin1/modules/Product_Options/product_options.tpl after :: Code:
add the following :: Code:
c) $xcart_dir/skin1/customer/main/product.tpl near the top of the file, directly after :: Code:
add the following :: Code:
Step 4: Modify the following Javascript file: a) $xcart_dir/skin1/modules/Product_Options/func.js after :: Code:
add the following :: Code:
Step 5: Add the following language variable - 'txt_custom_product_options_js_note' with the value: Code:
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:
I hope this is useful to someone, and suggestions/improvements are most welcome. Regards, Nate
__________________
-- Nathan T. Harper Nth Degree Consulting Web Dev / E-Commerce / ID Management X-Cart v4.1.9 + SpecialOffers + Magnifier + GiftReg + Survey + Custom tweaks FreeBSD + Apache 2.2.6 + PHP 5.2.3 + MySQL 5.0.24 |
|||||||
#8
|
|||||||
|
|||||||
![]() 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
__________________
-- Nathan T. Harper Nth Degree Consulting Web Dev / E-Commerce / ID Management X-Cart v4.1.9 + SpecialOffers + Magnifier + GiftReg + Survey + Custom tweaks FreeBSD + Apache 2.2.6 + PHP 5.2.3 + MySQL 5.0.24 |
|||||||
#9
|
|||||||
|
|||||||
![]() by the looks of the screen shot, you are using product.tpl...just put a if statement and in a javascript put
Code:
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 |
|||||||
#10
|
|||||||
|
|||||||
![]() 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
__________________
-- Nathan T. Harper Nth Degree Consulting Web Dev / E-Commerce / ID Management X-Cart v4.1.9 + SpecialOffers + Magnifier + GiftReg + Survey + Custom tweaks FreeBSD + Apache 2.2.6 + PHP 5.2.3 + MySQL 5.0.24 |
|||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|