Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Product options in product list

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-14-2012, 05:18 AM
 
tomsell tomsell is offline
 

Member
  
Join Date: Feb 2009
Posts: 13
 

Default 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!
__________________
4.1.11
Reply With Quote
  #2  
Old 05-14-2012, 05:46 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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:
{if $active_modules.Product_Options ne "" and $product.is_product_options eq 'Y'}
      <
tr>
        <
td>
          <
h2>Product Options</h2>
          {foreach 
from=$product_options item=options}
            <
b>{$options.classtext}</b> - 
            {foreach 
from=$options.options item=option name=option_loop}
              {
$option.option_name}{if not $smarty.foreach.option_loop.last},{/if}
            {/foreach}<
br />
          {/foreach}
        </
td>
      </
tr>
    {/if} 
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 05-14-2012, 06:12 AM
 
tomsell tomsell is offline
 

Member
  
Join Date: Feb 2009
Posts: 13
 

Default 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?
__________________
4.1.11
Reply With Quote
  #4  
Old 05-14-2012, 06:25 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #5  
Old 05-14-2012, 07:08 AM
 
tomsell tomsell is offline
 

Member
  
Join Date: Feb 2009
Posts: 13
 

Default 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
__________________
4.1.11
Reply With Quote
  #6  
Old 05-14-2012, 07:20 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #7  
Old 05-14-2012, 08:01 AM
 
SamuraiCoder SamuraiCoder is offline
 

Member
  
Join Date: May 2011
Posts: 25
 

Default 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.
__________________
Version 4.4.2
Reply With Quote
  #8  
Old 06-21-2012, 10:31 AM
 
xcellere xcellere is offline
 

Advanced Member
  
Join Date: Feb 2008
Posts: 32
 

Default 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?
__________________
Sunthing Productions
Version 4.5
Reply With Quote
  #9  
Old 06-21-2012, 12:31 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Product options in product list

Quote:
Originally Posted by xcellere
I have the same problem as the OP. How do I load that array?
After reading back through this thread, I realized that I never understood what the thread was really about. You guys are trying to display the options on the product list, for instance on category pages. I was showing you code that should work on the product page itself. Sorry. Just going too fast, I need to slow down.

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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
xcellere (06-21-2012)
  #10  
Old 06-21-2012, 12:36 PM
 
xcellere xcellere is offline
 

Advanced Member
  
Join Date: Feb 2008
Posts: 32
 

Default 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:
{* $Id: customer_options.tpl,v 1.4.2.1 2010/12/15 09:44:41 aim Exp $ vim: set ts=2 sw=2 sts=2 et: *} {if $product_options ne '' or $product_wholesale ne ''} {if $nojs ne 'Y'} <tr style="display: none;"> <td colspan="3"> <script type="text/javascript"> //<![CDATA[ var alert_msg = '{$alert_msg|wm_remove|escape:javascript}'; //]]> </script> {include file="modules/Product_Options/check_options.tpl"} </td> </tr> {/if} {foreach from=$product_options item=v} {if $v.options ne '' or $v.is_modifier eq 'T' or $v.is_modifier eq 'A'} <tr> <td class="property-name product-input"> {if $usertype eq "A"} {$v.class} {else} {$v.classtext|escape|default:$v.class} {/if} </td> <td class="property-value" colspan="2"> {if $cname ne ""} {assign var="poname" value="$cname[`$v.classid`]"} {else} {assign var="poname" value="product_options[`$v.classid`]"} {/if} {if $v.is_modifier eq 'T'} <input id="po{$v.classid}" type="text" name="{$poname}" value="{$v.default|escape}" /> {elseif $v.is_modifier eq 'A'} <textarea id="po{$v.classid}" name="{$poname}">{$v.default|escape}</textarea> {else} <select id="po{$v.classid}" name="{$poname}"{if $disable} disabled="disabled"{/if}{if $nojs ne 'Y'} onchange="javascript: check_options();"{/if}> {foreach from=$v.options item=o} <option value="{$o.optionid}"{if $o.selected eq 'Y'} selected="selected"{/if}> {strip} {$o.option_name|escape} {if $v.is_modifier eq 'Y' and $o.price_modifier ne 0} &nbsp;( {if $o.modifier_type ne '%'} {currency value=$o.price_modifier display_sign=1 plain_text_message=1} {else} {$o.price_modifier}% {/if} ) {/if} {/strip} </option> {/foreach} </select> {/if} </td> </tr> {/if} {/foreach} {/if} {if $product_options_ex ne ""} <tr> <td class="warning-message" colspan="3" id="exception_msg" style="display: none;"></td> </tr> {if $err ne ''} <tr> <td colspan="3" class="customer-message">{$lng.txt_product_options_combinations_warn}:</td> </tr> {foreach from=$product_options_ex item=v} <tr> <td colspan="3" class="poptions-exceptions-list"> {foreach from=$v item=o} {strip} <div> {if $usertype eq "A"} {$o.class} {else} {$o.classtext|escape} {/if} : {$o.option_name|escape} </div> {/strip} {/foreach} </td> </tr> {/foreach} {/if} {/if}
__________________
Sunthing Productions
Version 4.5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020