Different agrrement.html for different products

Discussion in 'Templates customization' started by mariusz04, Oct 27, 2007.

  1. mariusz04

    mariusz04 New Member

    Joined:
    Sep 4, 2007
    Messages:
    4
    Hello,

    On our site we have 4 membership levels. Each membership level has to have its own membership agreement so 1 global one is no use.

    Our programmer has already achieved showing only 1 product via calling it by id but if i turn on the tickbox for show agreement it calls the same agreement for all products???

    Please help???
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You can include different text in agreement.html template depending on product_id
    Here is example
    {if $smarty.request.product_id == 1}
    show agreement for product 1
    {elseif $smarty.request.product_id == 2}
    show agreement for product 2
    {else}
    show default agreement.
    {/if}
  3. mariusz04

    mariusz04 New Member

    Joined:
    Sep 4, 2007
    Messages:
    4
    hi there,
    thanks so much for your helpful reply. Can i just clarify the process you would recommend for calling individual products. If i add the above code to my signup.html page what would a sample url be for calling a single product.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Have a look to aMember CP -> Manage Products -> Edit product -> Price Group.
    If you want to use that code on signup page and will use price groups to show only individual products you will need to modify code a little:
    {if $smarty.request.price_group == 1}
    show agreement for product 1
    {elseif $smarty.request.price_group == 2}
    show agreement for product 2
    {else}
    show default agreement.
    {/if}
  5. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    This is how I'd probably do it- seperate each agreement text into its own page for ease of editing.

    {if $smarty.request.product_id == 1}

    {include file="agreement-product1.html"}

    {elseif $smarty.request.product_id == 2}

    {include file="agreement-product2.html"}

    {else}
    {include file="agreement-default.html"}
    {/if}

    David
  6. poirot

    poirot New Member

    Joined:
    May 29, 2008
    Messages:
    12
    The above does not seem to work for me.
    It seems that if you have different products and a member has already agreed to the agreement when he bought his first product, there will never be another agreement shown when he buys another product.
    I have set all my products so that agreement is required for all of them, but it only asks for the agreement for the first product bought by a member.
  7. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    That sounds like something that needs to be changed in a core amember file- Suggest you send a suppost ticket, and ask them after what they did so you can post the how to here :)

    David
  8. poirot

    poirot New Member

    Joined:
    May 29, 2008
    Messages:
    12
    I got the following reply from Alex a few hours ago (check the response time :) )
    It is possible to have a different agreement for each product, when people can buy more than one product.

    Replace code in member.php:

    if ($display_agreement && !$member['data']['i_agree'] && !$vars['i_agree']){
    display_agreement(serialize($vars)); // defined in the product.inc.php
    exit();
    }
    to:
    if ($display_agreement && !$vars['i_agree']){
    display_agreement(serialize($vars)); // defined in the product.inc.php
    exit();
    }

    Then an agreement will be shown each time (even it was displayed already for same product).

    I implemented that and it works.
    But now I have the following trouble, I tried to implement Alex's suggestion above:

    {if $smarty.request.product_id == 1}
    show agreement for product 1
    {elseif $smarty.request.product_id == 2}
    show agreement for product 2
    {else}
    show default agreement.
    {/if}

    And that seems to work fine, except that I have 4 products, and the above code only allows for 3 products.
    I am not a PHPer and nothing I tried works :(
  9. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello

    I don't know is this a trick question?

    To have 4 different agreements and 1 default agreement wouldn't it just be the following:

    PHP:
    {if $smarty.request.product_id == 1}
    show agreement for product 1
    {elseif $smarty.request.product_id == 2}
    show agreement for product 2
    {elseif $smarty.request.product_id == 3}
    show agreement for product 3
    {elseif $smarty.request.product_id == 4}
    show agreement for product 4
    {else}
    show default agreement.
    {/if} 
    Jimmy
  10. poirot

    poirot New Member

    Joined:
    May 29, 2008
    Messages:
    12
    No, it is not a trick question and it is not that simple :confused: .
    What you suggest is exactly what I tried before, but then you get the following error:

    ERROR [256] Smarty error: [in agreement.html line 30]: syntax error: unclosed tag \{elseif} (opened line 10). (Smarty_Compiler.class.php, line 303) in line 1102 of file /public_html/amember/smarty/Smarty.class.php

    It is the opening and closing bits that trip me up, whatever I try.
  11. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello,

    Post your agreement.html. My previous post was not right but I edited it to be right.

    Jimmy
  12. poirot

    poirot New Member

    Joined:
    May 29, 2008
    Messages:
    12
    I got some help from aMember in the meantime and they suggested the following /templates/agreement.html
    AND IT WORKS (of course)!

    Below is the full code of /templates/agreement.html

    Code:
    {assign var="title" value=$smarty.const._TPL_AGREEMENT_TITLE}
    {include file="header.html"}
    {include file="error.inc.html"}
    
    <p>#_TPL_AGREEMENT_REED_AGREE#</p>
    
    {php}
    $temp=unserialize($this->_tpl_vars['data']);
    $this->assign('product_id',$temp['product_id'][0]);
    {/php}
    {if $product_id eq 1}
    TEXT FOR PRODUCT 1
    {/if}
    {if $product_id eq 2}
    TEXT FOR PRODUCT 2
    {/if}
    {if $product_id eq 3}
    TEXT FOR PRODUCT 3
    {/if}
    {if $product_id eq 4}
    TEXT FOR PRODUCT 4
    {/if}
    
    <form method="post" action="{$smarty.server.PHP_SELF|escape}">#_TPL_AGREEMENT_AGREE#<input type="checkbox" name="i_agree" value="1" />
    
    <input class="input" type="submit" value="#_TPL_AGREEMENT_CONTINUE_BUT#" />
    <input type="hidden" name="do_agreement" value="1" />
    <input type="hidden" name="data" value="{$data|escape}" />
    </form>
    
    {include file="footer.html"}
    Thanks all for your help.
  13. poirot

    poirot New Member

    Joined:
    May 29, 2008
    Messages:
    12
    In the example in the previous post you can also use this code:

    {if $product_id eq 2 or $product_id eq 3}
    TEXT FOR PROCT 2 OR 3
    {/if}

    This can be helpful if you have maybe two products that use the same agreement, and another two that use a different agreement.
    Using this code you do not have to duplicate your agreement for different products.

Share This Page