| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Product options on products.tpl | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Product options on products.tpl
Has anyone or can anyone figure out how to get product options to display while viewing multiple products?
I already have an the add to cart and quantity showing on this page but am totally stumped for getting options to show. Any help would be greatly appreciated!! |
|||||||
#2
|
|||||||||
|
|||||||||
This requires quite a bit of backend PHP modifications for such to exist. If you wish you can submit a request to me via the link in my signature and I can provide you quote for such modifications.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart. |
|||||||||
#3
|
|||||||
|
|||||||
Boomer
This is quite an interesting one to solve - just did it myself for a client.
__________________
ex x-cart guru |
|||||||
#4
|
|||||||||
|
|||||||||
Almost finished my own version...
If anyone wants to clue me into how you chose to write your javascript validation and exceptions code to work on multiple products on the same page, I'd love to hear it. I don't need the code, just the logic. I've resorted to using a preg_replace to parse out the function names and give them numbers. Was this part of your solutions or did you find a more elegant approach?
I've got the code working on my test server (though I still need to add the quantity select menu to the products.tpl) with only one minor problem left to solve (one of my Javascript functions is being incorrectly numbered because I'm using the wrong increment variable). Post UPdate: I think I've finally conquered this one. It was definitely a brain teaser and I still haven't tested it with the validation exceptions, but now my script displays product options (but not quantity) on the products.tpl page. It ain't pretty and I had to stoop so low as to grab some php array values by numeric index rather than by associative index and do some lame preg_replace-ing, but it seems to work for me. I'll post the results of my hair-pulling session in a bit.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#5
|
|||||||||
|
|||||||||
Solution to product options on products.tpl
Well it was harder than it should have been and this may not be the best way, but here's the code to do it in xcart 3.3.1.
You will need to modify the following files: customer/products.php skindirectory/customer/main/products.tpl And you'll need to create the following file: skindirectory/Modules/Product_Options/customer_options_productspage.tpl I am pasting the code below with no warranty whatsoever. I have left extensive comments in the customer_options_productspage.tpl where certain functionality remains unfinished because I don't need it yet. It is also there to give other programmers a possible starting point for finishing this script. Note: among the unimplemented functionality is price modification based on chosen options. In other words, if you have options that modify the price of your product, this code will not work as is. Othewise, you should be okay using this code, but I don't guarantee it. Here's the code: customer/products.php Code:
skindirectory/customer/main/products.tpl Code:
skindirectory/modules/Product_Options/customer_options_productspage.tpl Code:
The above code really needs some cleaning up and there's still some code in there for my own custom mods that you may not have. I'll come back later and clean it up if anyone wants me to. Enjoy.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#6
|
|||||||
|
|||||||
Thanks
Thanks minorgod for posting this. It is Greatly Appreciated!
I haven't tried it out yet but I will take a look through it right away. I do need prices to change based on different options but I will see if I can figure that out and post it back here. If you get that figured first I'd love to see it. Thanks again, Marty |
|||||||
#7
|
|||||||||
|
|||||||||
Just pay attention to all the code I commented out. It would probably be easier for you to just delete all that extra code and start writing your own price modifier from scratch or based on the original product options code. If you need any explanation of what's happening in my code, just let me know. It's still working great for me, but it's only tested in my version of x-cart which is heavily modified already (so much so that I will probably never be upgrading). Good luck, and please do post your results if you figure it out.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#8
|
|||||||
|
|||||||
Not working properly
I tried the code but am getting just the empty text field instead of the options. For some reason the product_options array isn't loading in. I don't quite understand where you got the index array #4 from. Maybe it needs to be different for me since it isn't an associative array. That's all I can think of right now that might not be making it work properly.
If you could explain your code a bit, that might help me. Thanks, Marty |
|||||||
#9
|
|||||||||
|
|||||||||
You should modify your xcartdir/smarty.php file. Change the line that reads
Code:
Code:
Now launch your store in webmaster mode...open a new customer window and browse to a product category where the options should be displaying. In the debug window you will see a full list of all assigned PHP variables and their values. In my PHP code, I used the numeric index [4] because I didn't see an associative index containing my options as a string (which needs to be parsed by the func_parse_options() function). Look for an index in the $products[i][product_options] array that contains your options as such and replace the index [4] with whatever that index turns out to be. This might fix things for you. The original product options code was designed to work with only a single product and therefore the old code produces a $product_options array which only holds options for the specific product being viewed on the detail page. Since our new script must keep track of options for more than one product, I've simply extended the $products array which is already generated by x-cart, to include product_options with each product. So my code essentially loops through the $products array, and creates a sub array in each product called "product_options". Oh...and your empty text field showing up, means that the code is nearly working...it just can't find the parsed options. The options code is designed to default to an empty text field if you haven't specified any options (such as blue\n,yellow\n,red\n,etc.) when setting up your options for that product in the admin interface. So it seems you are on the right track. I think if you fix that array index to point to a valid index, it should work for you. Let me know if you have any luck.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#10
|
|||||||
|
|||||||
Got the box to fill
I figured out the associative array and now the option box is populating properly. Instead of putting the number 4 in you just have to put 'options' in. For some reason the hyperlink to the detail page isn't working properly for me with your template code. I am going to have to look in to that now and then I will try to figure out the pricing issues.
Thanks for your help. The modified debugging window really helps. I didn't know about that one. Thanks, Marty |
|||||||
|
|||
X-Cart forums © 2001-2020
|