Jump to content

Needing a conditional statement for, 4 of the same products with the same pid


Recommended Posts

On the clientareaproductdetails.tpl I have a conditional statement that I can't get my head around, using the clients serviced/id.

 

Scenario

Customer has purchased 4 of the same products with the same pid/name (let’s call the product – Test).

This product has been setup that the 1st time they purchase this product in the cart they fill in custom field (1 & 2), the 2nd time they purchase the product, custom field (3 & 4), the 3rd time purchase the product custom field (5 & 6) and the 4th custom field (7 & 8)

 

The custom fields are dates and reference numbers.

 

I need to be able to show the individual custom fields on the clientareaproductdetails.tpl.

 

The problem is that, and this is what I can’t get my head around, I can’t find a way to call the service ID and allocate the fields needed for that service ID, do I need a hook to do this? And if so does someone have one that will do the trick?

 

Knowing that the service id will always change, I can’t just put a figure.

 

i.e. Purchase 1 - Test, show custom field 1 & 2

Purchase 2 - Test, show custom field 3 & 4

Purchase 3 - Test, show custom field 5 & 6

Purchase 4 - Test, show custom field 7 & 8

 

Does this make sense?

 

{if $serviceid == '(4th product purchased)'}
<input type="text" name="" id="" value="{$clientsdetails.customfields8}" class="form-control" disabled/>
<input type="text" name="" id="" value="{$clientsdetails.customfields7}" class="form-control" disabled/>

{elseif $serviceid == '(3rd product purchased)'}
<input type="text" name="" id="" value="{$clientsdetails.customfields6}" class="form-control" disabled/>
<input type="text" name="" id="" value="{$clientsdetails.customfields5}" class="form-control" disabled/>

{elseif $serviceid == '(2nd product purchased)'}
<input type="text" name="" id="" value="{$clientsdetails.customfields4}" class="form-control" disabled/>
<input type="text" name="" id="" value="{$clientsdetails.customfields3}" class="form-control" disabled/>

{elseif $serviceid == '(1st product purchased)'}
<input type="text" name="" id="" value="{$clientsdetails.customfields2}" class="form-control" disabled/>
<input type="text" name="" id="" value="{$clientsdetails.customfields1}" class="form-control" disabled/>

{/if}

 

 

Thanks again

Kev

Link to comment
Share on other sites

The custom fields are Client custom fields, there is a long story to this one. They can't be product custom fields.

But the issue I'm having is I need to add an {if} statement that shows the appropriate client custom field in relation to the order the product has been purchased, as in the i.e. above.

Any idea's?

 

Thanks again for your time.

Link to comment
Share on other sites

You'll be able to show the additional fields on the service page, or specifically that service's page, yes.

Alternatively, you can probably throw a quick hook together to get what you need done, but you really want to make sure that this is associated with the correct product (ie: in the product custom fields) before you do that :)

Link to comment
Share on other sites

Thank you all fixed.

On another topic, this should also be easy, I've manually added custom fields to our cart.tpl but I would like to make some of them required fields.

I've tried {$required} and {{customfield.required} but neither work, I can't seem to find the answer to this anywhere.

 

{foreach key=num item=customfield from=$customfields}
{if $customfield.name eq "SMS Number"}
<div class="form-group">
<label class="control-label">SMS Mobile No (e.g. +61 412345678)</label>
<div class="control">{$customfield.input} {$required}
</div>
</div>
{/if}
{/foreach}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated