X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Auto assign product category (https://forum.x-cart.com/showthread.php?t=16042)

delphighse 08-19-2005 03:37 PM

Auto assign product category
 
Can anyone help me figure this out? When a provider creates a new product I am trying to automatically assign Category 2 with the $login of that provider. I know it is in the product_modify.tpl. I would just like to know how to assign a value that will be written to the products_categoryid1 when the new product is created.
I have been working with this section of the product_modify.tpl and have tried everything I know but I just can't figure it out.

<TR>
<TD class="TableCenterProductDetails">{$lng.lbl_catego ry2}</TD>
<TD class="TableCenterProductDetails">
<SELECT name="categoryid1">
<OPTION value=0 {if $product.categoryid1 eq "0"}selected{/if}>{$lng.lbl_undefined}</OPTION>
{section name=cat_num loop=$allcategories}
<option value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid1}selected{/if}>{ $allcategories[cat_num].category }</option>
{/section}
</SELECT></TD>
</TR>

If anyone can help me I would be so very grateful. Thanks very much.
Becky
Xcart V. 3.2.4

delphighse 08-20-2005 11:10 AM

I am attempting to assign the category 2 of a product automatically and I have changed product_modify.tpl from this:

<TR>
<TD class="TableCenterProductDetails">{$lng.lbl_catego ry2}</TD>
<TD class="TableCenterProductDetails">
<SELECT name="categoryid1">
<OPTION value=0 {if $product.categoryid1 eq "0"}selected{/if}>{$lng.lbl_undefined}</OPTION>
{section name=cat_num loop=$allcategories}
<option value="{$allcategories[cat_num].categoryid}" {if $allcategories[cat_num].categoryid eq $product.categoryid1}selected{/if}>{ $allcategories[cat_num].category }</option>
{/section}
</SELECT></TD>
</TR>

To This:

{assign var="categoryid1" value="Vendors/$login "}
{section name=cat_num loop=$allcategories}
{if $categoryid1 eq $allcategories[cat_num].category}
{assign var="product.categoryid1" value="$allcategories[cat_num].categoryid"}
{else}
{$categoryid1|count_characters:true}
{$allcategories[cat_num].category|count_characters:true}
{$allcategories[cat_num].category}{$categoryid1}

{/if}
{/section}

The problem I am having is that the variable $categoryid1 is not eq to the $allcategories[cat_num].category. In the else statement I am verifying that the character count is the same as well as the value. When I run this I can verify that there is a match but the compare is turning up false. What am I doing wrong? Any help would be very much appreciated. It's probably something very simple, but I have spend days on this and can't seem to come up with the answer.
Thanks very much.
Becky
xcart V3.2.4

delphighse 08-20-2005 01:22 PM

Well, I think I may be getting close to a solution for my problem.

{assign var="categoryassign" value=" Vendors/$login"}
{section name=cat_num loop=$allcategories}
{if $categoryassign eq $allcategories[cat_num].category}
{assign var="categoryid1" value=$allcategories[cat_num].categoryid}
{/if}
{/section}

This works very well with the categoryid1$ assigned with the automatic category, but it does not store in the database. I assume it is not being passed to the include/product_modify.php.
How can I get the value back to the php?
Thanks for your help.
Becky
xcart v 3.2.4


All times are GMT -8. The time now is 11:04 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.