Product options in product list
Hi, is there a change to add product option (price modifier etc...) to show in products list? For example under {$product.descr}? Thanks for advance!
|
Re: Product options in product list
I haven't tested this yet, but it should work fine to display the options. Written for 4.4.5, you may need to modify it for your version. I also assumed you would be placing it within a table, you may need to adjust or remove the row and column tags.
PHP Code:
|
Re: Product options in product list
Thanks a lot for the quick answer! Well, it just displays the titel "Product Options" not the options itself. Do You have a hint, what would be wrong?
|
Re: Product options in product list
Tom, I just tested it on my test site: http://trainingpen.com/Acer-TravelMate-212T.html it is working just as I expected it to. I would try and look at the variables in webmaster mode, and see if they are set or not.
Product option variables may have different names or arrangement in your version. I am using 4.4.5. When you fire up webmaster mode, click the button that shows the variables instead of template names. Then check the variable names. Do you have an array named $product_options? Use control-F to search the debug console window. |
Re: Product options in product list
In my version there is not possible to show variables instead of template names I guess. But yes, the array named $product options is present
|
Re: Product options in product list
It is probably possible for you to see the variables, but you need to apply a patch, or set the debug mode in config.php (I think)
Look at this thread: http://forum.x-cart.com/showthread.php?t=44543&highlight=debug You can also choose to print the entire array with the smarty command: {$product_options|@print_r} Then you can see the variables that you need to access, and figure out why the code isn't working. Your version must refer to the options differently. I suspect it might not have the classtext part, maybe it is optiontext or something else in 4.1.11. |
Re: Product options in product list
Hi,
Does anyone have any ideas on how to add product variants to the product list page. I'm having a look at the customer_options.php page but can't seem to find how to make sure its added on the product list page. |
Re: Product options in product list
I have the same problem as the OP. When I add the code, the title is all that shows, just no drop down. I did check the variables and $product_options isn't there. How do I load that array?
|
Re: Product options in product list
Quote:
You can load the array yourself in php, but you need to determine where the values are pulled from, and access them in the DB. I don't have a quick answer for you unfortunately, I have no idea how product options are handled in 4.1.X But lets start figuring it out! First lets see how the product options are pulled on the product page. We already have a clue from SamuraiCoder: customer_options.php. Do you have that file in 4.1.X? I think we can assume it is referenced in product.php. So when we pull up the product page, we are really accessing product.php, and then in turn it is including or requiring customer_options.php. My first step would be to verify that the assumptions I have made above are true, by looking through product.php. Then if so, I would pull open customer_options.php and take a look at how the options were being accessed. Armed with that knowledge we can start determining where we need to add code to pull these options on the page in question. I believe that the products list is generated by search.php. The actual page we are on when looking at a category is home.php?cat=(somenumber). When ?cat= is included it sets a variable $cat, and the value which is the categoryid. If this is the case it includes search.php (I think) and the database is queried for the products in that category. Our mission is to understand the inner workings of that query, and add the lines that we found in customer_options.php or some variation of those lines. What we are trying to do is pull the product option values for each product found, and assign them to the $products array. Sorry for the long post, just trying to make sure even a noob could understand. Hopefully that helps. |
Re: Product options in product list
Thank you for such a detailed post Mike. I should note that I just updated my signature to show my current version: 4.5. :) No longer 4.1.
EDIT: This is the code in customer_options.tpl: Code:
{* |
Re: Product options in product list
I got it to "kind of" work. You have to hit the Add to Cart button, and then after like 5 seconds, it loads the product options. Anyone know how I can get the product options to be there when the page loads? http://www.medilogic-collective.com/xcart/indica/
When the page loads, the $product_options array isn't loaded. Thoughts? |
Re: Product options in product list
Okay here is step 1 to solving the problem in 4.4.X:
Open up /products.php and near line 135 insert this code: PHP Code:
PHP Code:
PHP Code:
This will get the options assigned to the product list in a category. Now you should be able to view the options in webmaster mode. |
Re: Product options in product list
Okay, now lets get our options to display in the template.
Edit /common_files/customer/main/buy_now.tpl Near line 54: After: PHP Code:
PHP Code:
Before: PHP Code:
Please note you will need to have the Buy Now buttons enabled in the admin. Also if this change throws off your template, try replacing the <div class="quantity"> and the </div> with table tags. So the added code would read: PHP Code:
|
Re: Product options in product list
When testing this, my client and I discovered that the product options disappeared once the add to cart button was pressed.
To fix this, edit /include/func/func.ajax.php: Around line 105, After: PHP Code:
Insert: PHP Code:
PHP Code:
|
Re: Product options in product list
Going even further, here is how to modify the javascript to get the product price to update when the product option is changed. //This will not work with product variants, or with wholesale prices
We begin by submitting the product id with the onchange event: In /my_skin/modules/Product_Options/customer_options.tpl near line 48: Replace: PHP Code:
PHP Code:
Next before we dive into the JS, lets set the span ID to include the productid on the product page: In /customer/main/product_details.tpl near line 80: After: PHP Code:
PHP Code:
Replace: PHP Code:
PHP Code:
Note: the below code references the product price in the template products_list.tpl, you may be using products_t.tpl instead, if your products are arranged in multiple columns. This depends on the settings under General Settings/Appearance - Displaying products. In this case, look near line 116 and make the edit to the span as described below, and include the capture above it. And on the category page: In /customer/main/products_list.tpl near line 70: After: PHP Code:
PHP Code:
Replace: PHP Code:
PHP Code:
|
Re: Product options in product list
1 Attachment(s)
Here is where things get a bit tricky. :-)
Let's start modifying the product options Javascript. In /modules/Product_Options/check_options.tpl near line 27: Before: PHP Code:
PHP Code:
Then, near line 76: After: PHP Code:
PHP Code:
PHP Code:
Next, near line 159: Replace: PHP Code:
PHP Code:
I have attached the whole file with the edits just in case. |
Re: Product options in product list
1 Attachment(s)
Now we dive into the actual script itself, lot of edits to make here.
In /my_skin/modules/Product_Options/func.js near line 21: After: PHP Code:
PHP Code:
PHP Code:
Next, near line 35: After: PHP Code:
PHP Code:
Next, near line 162: After: PHP Code:
PHP Code:
PHP Code:
Next, near line 198: After: PHP Code:
PHP Code:
PHP Code:
Then, near line 315: After: PHP Code:
PHP Code:
PHP Code:
Well that's it! Hope it has been enlightening and entertaining. Remember this is just a quick little hack, it will not work in all instances, and there are certainly better ways to do this if you spent more time investigating it than I have. But it should get you started towards a more robust solution if that is your intention. I have again uploaded the whole func.js file just in case I missed something. I renamed it to func.tpl so the forum would accept it. |
Re: Product options in product list
Does this work for variants?
|
Re: Product options in product list
Any way we can use this code to show product options in new arrivals & on sale module product lists?
|
Re: Product options in product list
@Richard,
I'm not really sure! I'd have to test it. Sorry for the 2 year late reply. :-) @Marcello, I don't see why not. This code is pretty old now, I haven't used it again or tested in several years. I'm sure that large portions of it still apply, but it would need to be tested along the way as you were implemented, not just blindly followed. It should point you in the right direction at least! |
Re: Product options in product list
We've gotten it to at least pass the product options to product list.
What we're basically trying to do, is use the code you added to /products.php in post #12 in this thread. We're using this to show an image that says "Options Available!" over top of the product thumbnails in any product list on our site (we use products_t.tpl). But since New Arrivals and On Sale products are populated in a different area, we can't get it to work with them. Tried putting the code from products.php into new_arrivals.php and on_sale.php but it didn't work. Though it did work for manufacturers.php (but I think that's because the manufacturers.php product array may be pulled from the same array products.php uses). See: silverhorseracing.com to view what we are doing. Right now we have if statements: Code:
{if $product.is_product_options eq "Y"} |
Re: Product options in product list
Thanks TotalTec. I added the modification to my website (x-cart 4.1), and it works great. It only shows the product options on the category pages, and I'd like to see if there is a easy way to make it show on all of the pages that show a product list (ex. search, featured products etc).
I used to code out of the post dated 06-22-2012, 09:46 AM and 06-22-2012, 10:10 AM. |
Re: Product options in product list
Hi Mike,
How is it going? thanks for posting this mode. did you manage to make it work with variants and wholesale prices? |
Re: Product options in product list
Anton,
Good to hear from you friend! I have not messed with this for years, I don't think I ever worked on variants and wholesale prices for this. It is something I could code for sure if a client was interested. These days though, its hard to find the time to do stuff like this without having a paying client to do it for. |
Re: Product options in product list
yes, free is overrated nowadays :)
we are almost done with it anyway. see you soon in Chicago. |
All times are GMT -8. The time now is 09:03 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.