Jump to content

How to display the voucher box only for a specific client group


Recommended Posts

Hi,

 

I use Prestashop 1.4.7.

 

I created some vouchers only dedicated to a specific client group.

 

On the front office, I would like that the voucher box only displays when a client belonging to this specific client group is logged.

 

I thank you in advance for any piece of information useful to reach this goal.

 

 

Patrick

Link to comment
Share on other sites

in this case you will need to create if condition in shopping-cart.tpl file,

you need to create if with:

 

{if $logged}

  {if $customer_group==5}

    VOUCHER FIELD HERE

  {/if}

{/if}

 

to get customer_group  variable you will need to pass it to the smarty array in cart controller

Link to comment
Share on other sites

Hi,

Thank you vekia for this prompt reply.

1- Currently in shopping-cart.tpl, I have the following code :
<tr class="cart_total_voucher" {if $total_wrapping == 0}style="display: none;"{/if}>

Could you tell me more precisely what I have to put now in this file ?

2- As I am not very familiar with coding, could you give me more details about the way to "to pass it to the smarty array in cart controller".

Sorry to not be able to do it alone.

Thank you again in advance.

Patrick

Link to comment
Share on other sites

Hi,

1- I finally managed to display the voucher box, on the front office, only for registered clients.

To do this, I amended the shopping-cart.tpl file as follows :

Original code :
{if $voucherAllowed}
<div id="cart_voucher" class="table_block">
...
</div>
{/if}

Amended code :
{if $logged}
{if $voucherAllowed}
<div id="cart_voucher" class="table_block">
...
</div>
{/if}
{/if}

2- But the best (as to me) would be to display the voucher box only for clients for which a voucher has been created in the back office.
    - either the voucher has been created for several single clients
    - or the voucher has been created for a group to which the client belongs

I thank you in advance for any help to display the voucher box only for clients for which a voucher has been created in the back office

Patrick

Link to comment
Share on other sites

                    {if $logged}
                      {if $checkcustomer->id_default_group==3}
     <form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="voucher">
     <fieldset>
     <p class="title_block"><label for="discount_name">{l s='Vouchers'}</label></p>
     <p class="discount_name_block">
     <input type="text" class="discount_name" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
     </p>
     <p class="submit"><input type="hidden" name="submitDiscount" /><input type="submit" name="submitAddDiscount" value="{l s='OK'}" class="button" /></p>
     </fieldset>
     </form>
                      {/if}
                    {/if}

use code above in .tpl file

in addition, you will need to modify OrderController.php file located in controllers/front/ directory

 

there is a function:

public function initContent(){
parent::initContent();
...
...
...
}

add there:

public function initContent(){
parent::initContent();
$this->context->smarty->assign('checkcustomer',$this->context->customer);
...
...
...
}
Link to comment
Share on other sites

Hi,

Thank you very much for your detailed reply.

1- With the solution you gave me, could you tell me when the voucher box will be displayed :
    - when a client is logged and belongs to group 3
    - or when a client is logged and when a voucher has been created for this client ?

2-
In your post dated 10.42 am, you wrote :
 - about the tpl file :  {if $checkcustomer->id_default_group==3}
In your post dated 10.46 am, you wrote :
- about the OrderController.php file :
if ($this->context->customer->id_default_group==5)

Is it normal that the id_default_group is 3 in one file and 5 in the other file ?

Thank you again in advance,

Patrick

Link to comment
Share on other sites

1) with code that i pasted voucher box will appear for customer who is:

- logged

- belongs to group ID = 5 (see below)

 

2) my first post was only an example (something like a tip - "what to do to achieve it"), my latest reply is correct one, you need to use: if ($this->context->customer->id_default_group==5)

Link to comment
Share on other sites

Hi,

 

Thank you for your detailed reply.

 

Currently my code in the shopping-cart.tpl file is the following :

{if $logged}
{if $voucherAllowed}
<div id="cart_voucher" class="table_block">
	{if isset($errors_discount) && $errors_discount}
		<ul class="error">
		{foreach from=$errors_discount key=k item=error}
			<li>{$error|escape:'htmlall':'UTF-8'}</li>
		{/foreach}
		</ul>
	{/if}
        <div id="opc_voucher_errors" class="error" style="display: none;"></div>
	<form action="{$opckt_script}" method="post" id="voucher">
		<fieldset>
			<h4>{l s='Vouchers' mod='onepagecheckout'}</h4>
			<p>
				<label for="discount_name">{l s='Code:' mod='onepagecheckout'}</label>
				<input type="text" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
			</p>
			<p class="submit"><input type="hidden" name="submitDiscount" /><input type="submit" name="submitAddDiscount" value="{l s='Add' mod='onepagecheckout'}" class="button" /></p>
		{if $displayVouchers}
			<h4>{l s='Take advantage of our offers:' mod='onepagecheckout'}</h4>
			<div id="display_cart_vouchers">
			{foreach from=$displayVouchers item=voucher}
				<span onclick="$('#discount_name').val('{$voucher.name}');return false;" class="voucher_name">{$voucher.name}</span> - {$voucher.description} <br />
			{/foreach}
			</div>
		{/if}
		</fieldset>
	</form>
</div>
{/if}{/if}

Do I have to delete all this code and replace it by the code you give me ?

 

Thank you again in advance.

 

Patrick

Link to comment
Share on other sites

instead of code you paster use this one:

{if $logged}
{if $voucherAllowed}
{if $checkcustomer->id_default_group==3}
<div id="cart_voucher" class="table_block">
	{if isset($errors_discount) && $errors_discount}
		<ul class="error">
		{foreach from=$errors_discount key=k item=error}
			<li>{$error|escape:'htmlall':'UTF-8'}</li>
		{/foreach}
		</ul>
	{/if}
        <div id="opc_voucher_errors" class="error" style="display: none;"></div>
	<form action="{$opckt_script}" method="post" id="voucher">
		<fieldset>
			<h4>{l s='Vouchers' mod='onepagecheckout'}</h4>
			<p>
				<label for="discount_name">{l s='Code:' mod='onepagecheckout'}</label>
				<input type="text" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
			</p>
			<p class="submit"><input type="hidden" name="submitDiscount" /><input type="submit" name="submitAddDiscount" value="{l s='Add' mod='onepagecheckout'}" class="button" /></p>
		{if $displayVouchers}
			<h4>{l s='Take advantage of our offers:' mod='onepagecheckout'}</h4>
			<div id="display_cart_vouchers">
			{foreach from=$displayVouchers item=voucher}
				<span onclick="$('#discount_name').val('{$voucher.name}');return false;" class="voucher_name">{$voucher.name}</span> - {$voucher.description} <br />
			{/foreach}
			</div>
		{/if}
		</fieldset>
	</form>
</div>
{/if}
{/if}
{/if}

don't forget about controller modification!

Link to comment
Share on other sites

Hi,

Thank you for your reply and sorry to disturb you again.

1- as to you post dated yesterday 10:42 AM :

Could you confirm that I have to do the following in /controllers/OrderController.php :

    replacing the following code :

    public function init()
    {
        parent::init();
        $this->step = (int)(Tools::getValue('step'));
        if (!$this->nbProducts)
            $this->step = -1;
    }

by

    public function init()
    {
        parent::init();
        $this->context->smarty->assign('checkcustomer',$this->context->customer);
        $this->step = (int)(Tools::getValue('step'));
        if (!$this->nbProducts)
            $this->step = -1;
    }

2- As to your next post dated yesterday 10:46 AM :

I did not really understand what replacement or addition I have to do

 

Thank you in advance,

Patrick

Link to comment
Share on other sites

Hi vekia,

 

1- What I did in the Back office :

 

- amending the original shopping-cart.tpl code by putting two conditions instead of one only :

{if $logged}
{if $voucherAllowed}

{if $logged}
{if $voucherAllowed}
<div id="cart_voucher" class="table_block">
	{if isset($errors_discount) && $errors_discount}
		<ul class="error">
		{foreach from=$errors_discount key=k item=error}
			<li>{$error|escape:'htmlall':'UTF-8'}</li>
		{/foreach}
		</ul>
	{/if}
        <div id="opc_voucher_errors" class="error" style="display: none;"></div>
	<form action="{$opckt_script}" method="post" id="voucher">
		<fieldset>
			<h4>{l s='Vouchers' mod='onepagecheckout'}</h4>
			<p>
				<label for="discount_name">{l s='Code:' mod='onepagecheckout'}</label>
				<input type="text" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
			</p>
			<p class="submit"><input type="hidden" name="submitDiscount" /><input type="submit" name="submitAddDiscount" value="{l s='Add' mod='onepagecheckout'}" class="button" /></p>
		{if $displayVouchers}
			<h4>{l s='Take advantage of our offers:' mod='onepagecheckout'}</h4>
			<div id="display_cart_vouchers">
			{foreach from=$displayVouchers item=voucher}
				<span onclick="$('#discount_name').val('{$voucher.name}');return false;" class="voucher_name">{$voucher.name}</span> - {$voucher.description} <br />
			{/foreach}
			</div>
		{/if}
		</fieldset>
	</form>
</div>
{/if}{/if}

In this case, the voucher box displays :
- with the voucher code, for logged customers for whom a voucher has been created in the back office
- without the voucher code far any other logged customer
The voucher does not display for any non-logged customers

 

2- I tried to put 3 conditions in the shopping-cart.tpl.

{if $logged}

{if $voucherAllowed}
{if $checkcustomer->id_default_group==2}
{if $logged}
{if $voucherAllowed}
{if $checkcustomer->id_default_group==2}
<div id="cart_voucher" class="table_block">
	{if isset($errors_discount) && $errors_discount}
		<ul class="error">
		{foreach from=$errors_discount key=k item=error}
			<li>{$error|escape:'htmlall':'UTF-8'}</li>
		{/foreach}
		</ul>
	{/if}
        <div id="opc_voucher_errors" class="error" style="display: none;"></div>
	<form action="{$opckt_script}" method="post" id="voucher">
		<fieldset>
			<h4>{l s='Vouchers' mod='onepagecheckout'}</h4>
			<p>
				<label for="discount_name">{l s='Code:' mod='onepagecheckout'}</label>
				<input type="text" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
			</p>
			<p class="submit"><input type="hidden" name="submitDiscount" /><input type="submit" name="submitAddDiscount" value="{l s='Add' mod='onepagecheckout'}" class="button" /></p>
		{if $displayVouchers}
			<h4>{l s='Take advantage of our offers:' mod='onepagecheckout'}</h4>
			<div id="display_cart_vouchers">
			{foreach from=$displayVouchers item=voucher}
				<span onclick="$('#discount_name').val('{$voucher.name}');return false;" class="voucher_name">{$voucher.name}</span> - {$voucher.description} <br />
			{/foreach}
			</div>
		{/if}
		</fieldset>
	</form>
</div>
{/if}
{/if}
{/if}

But in the case of 3 conditions as above, the voucher box never displays.

 

I did the 2 above tests without amending the controller.php file (mainly as I did not understand what I should have to amend in this file).

 

Summary :
Therefore, I did not manage to reach my goal that would have been to display the voucher box only for logged customers belonging to a certain client group.
But maybe, my Prestashop version, as you said today, does not allow the achievement of my wish.

 

In case you kwow it, could you tell me how to introduce 3 conditions in the shopping-cart.tpl file ?

Thank you again.

 

Kind Regards,

Patrick

Link to comment
Share on other sites

Hi,

1- I did not make any change in the Controllers.php file.
So I used nothing instead of context object.

2- To make things more precise, I have to say that I use a module called onepagechekout.
So, the amendments that I made were located in /modules/onepagecheckout/shopping-cart.tpl (and not in themes/Mytheme/shopping-cart.tpl)
Following to the module developer, if I have to amend anything in the controller, it would have to be made in /modules/onepagecheckout/OrderOpcktController.php (and not in /controllers/OrderController.php)

Thank you again for any help.

Patrick

Link to comment
Share on other sites

Hi,

 

Thank you veka for your last reply, and sorry for my lack of knowledge in php.

 

If you have time enough, could you let me know what I have to amend either in /controllers/OrderController.php or in /modules/onepagecheckout/OrderOpcktController.php.

 

The beginning of the code of the /controllers/OrderController.php is :

ControllerFactory::includeController('ParentOrderController');

class OrderControllerCore extends ParentOrderController
{
	public $step;

	public function init()
	{
		parent::init();

		$this->step = (int)(Tools::getValue('step'));
		if (!$this->nbProducts)
			$this->step = -1;
	}

	public function preProcess()
	{
		global $isVirtualCart, $orderTotal;

		parent::preProcess();

The beginning of the code of  /modules/onepagecheckout/OrderOpcktController.php is :

ControllerFactory::includeController('ParentOrderController');

if(Configuration::get('VATNUMBER_MANAGEMENT') AND file_exists(dirname(__FILE__).'/../../modules/vatnumber/vatnumber.php'))
	include_once(dirname(__FILE__).'/../../modules/vatnumber/vatnumber.php');

class OrderOpcktController extends ParentOrderController {

    public $isLogged;

    public function __construct() {
        $this->guestAllowed = true;
		
        parent::__construct();
    }

    // function originally in ParentOrderController, updated for opckt needs
    private function origParentPreProcess() {
        if (Configuration::get('PS_CATALOG_MODE'))
            $this->errors[] = Tools::displayError('This store has not accepted your new order.');

        if (Tools::isSubmit('submitReorder') AND $id_order = (int) Tools::getValue('id_order')) {
            $oldCart = new Cart(Order::getCartIdStatic((int) $id_order, (int) self::$cookie->id_customer));
            $duplication = $oldCart->duplicate();
            if (!$duplication OR !Validate::isLoadedObject($duplication['cart']))
                $this->errors[] = Tools::displayError('Sorry, we cannot renew your order.');
            elseif (!$duplication['success'])
                $this->errors[] = Tools::displayError('Missing items - we are unable renew your order');
            else {
                self::$cookie->id_cart = $duplication['cart']->id;
                self::$cookie->write();
                Tools::redirect(_ORDEROPCKT_REL_PATH_);
            }
        }

        $this->_submitDiscount();
        
        self::$smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
    }//origParentPreprocess()

Thank you again in advance for any suggestion.

 

Patrick

Link to comment
Share on other sites

The /modules/onepagecheckout/shopping-cart.tpl file is as follows :

{*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2011 PrestaShop SA
*  @version  Release: $Revision: 1.4 $
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}

{capture name=path}{l s='Your shopping cart' mod='onepagecheckout'}{/capture}


{if !isset($opc_config.compact_form) || !$opc_config.compact_form}
{include file="$tpl_dir./breadcrumb.tpl"}
    <h1 id="cart_title">{l s='Shopping cart summary' mod='onepagecheckout'}</h1>
{/if}


{assign var='current_step' value='summary'}
{*include file="$tpl_dir./order-steps.tpl"*}
{include file="$tpl_dir./errors.tpl"}


{if !$productNumber}
	<p class="warning">{l s='Your shopping cart is empty.' mod='onepagecheckout'}</p>
{elseif $PS_CATALOG_MODE}
	<p class="warning">{l s='This store has not accepted your new order.' mod='onepagecheckout'}</p>
{else}
	<script type="text/javascript">
	// <![CDATA[
	var baseDir = '{$base_dir_ssl}';
	var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}';
	var currencyRate = '{$currencyRate|floatval}';
	var currencyFormat = '{$currencyFormat|intval}';
	var currencyBlank = '{$currencyBlank|intval}';
	var txtProduct = "{l s='product' mod='onepagecheckout'}";
	var txtProducts = "{l s='products' mod='onepagecheckout'}";
{* ajouté le 29-10-12, suggestion de Peter *}
var txtFreePrice = "{l s='Gratuit!' mod='onepagecheckout'}";
	
{if isset($onlyCartSummary)}
        var orderOpcUrl = '{$opckt_script}';
	var addressUrl = '{$link->getPageLink("address.php", true)}';
	var taxEnabled = {$use_taxes};
	var displayPrice = {$priceDisplay};
	var txtWithTax = "{l s='(tax incl.)' mod='onepagecheckout'}";
	var txtWithoutTax = "{l s='(tax excl.)' mod='onepagecheckout'}";		
	var opc_hide_carrier = '{$opc_config.hide_carrier}';
        var onlyCartSummary = '1';
{else}
        var onlyCartSummary = '0';
{/if}

	// ]]>
	</script>
	<p style="display:none" id="emptyCartWarning" class="warning">{l s='Your shopping cart is empty.' mod='onepagecheckout'}</p>
{if isset($lastProductAdded) AND $lastProductAdded}
	{foreach from=$products item=product}
		{if $product.id_product == $lastProductAdded.id_product AND (!$product.id_product_attribute OR ($product.id_product_attribute == $lastProductAdded.id_product_attribute))}
			<div class="cart_last_product">
				<div class="cart_last_product_header">
					<div class="left">{l s='Last added product' mod='onepagecheckout'}</div>
				</div>
				<a  class="cart_last_product_img" href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small')}" alt="{$product.name|escape:'htmlall':'UTF-8'}"/></a>
				<div class="cart_last_product_content">
					<h5><a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.name|escape:'htmlall':'UTF-8'}</a></h5>
					{if isset($product.attributes) && $product.attributes}<a href="{$link->getProductLink($product.id_product, $product.link_rewrite, $product.category)|escape:'htmlall':'UTF-8'}">{$product.attributes|escape:'htmlall':'UTF-8'}</a>{/if}
				</div>
				<br class="clear" />
			</div>
		{/if}
	{/foreach}
{/if}
{if !isset($opc_config.compact_form) || !$opc_config.compact_form}
<p>{l s='Your shopping cart contains' mod='onepagecheckout'} <span id="summary_products_quantity">{$productNumber} {if $productNumber == 1}{l s='product' mod='onepagecheckout'}{else}{l s='products' mod='onepagecheckout'}{/if}</span></p>
{/if}
<div id="order-detail-content" class="table_block">
	<table id="cart_summary" class="std">
		<thead>
			<tr>
				<th class="cart_product first_item">{l s='Product' mod='onepagecheckout'}</th>
				<th class="cart_description item">{l s='Description' mod='onepagecheckout'}</th>
				<th class="cart_ref item">{l s='Ref.' mod='onepagecheckout'}</th>
				<th class="cart_availability item">{l s='Avail.' mod='onepagecheckout'}</th>
				<th class="cart_unit item">{l s='Unit price' mod='onepagecheckout'}</th>
				<th class="cart_quantity item">{l s='Qty' mod='onepagecheckout'}</th>
				<th class="cart_total last_item">{l s='Total' mod='onepagecheckout'}</th>
			</tr>
		</thead>
               <div id="tfoot_static_underlay" class="sticky_underlay"></div>
		<tfoot id="tfoot_static">
			{if $use_taxes}
				{if $priceDisplay}
					<tr class="cart_total_price">
						<td colspan="6">{l s='Total products' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax excl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}</td>
						<td class="price" id="total_product">{displayPrice price=$total_products}</td>
					</tr>
				{else}
					<tr class="cart_total_price">
						<td colspan="6">{l s='Total products' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax incl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}</td>
						<td class="price" id="total_product">{displayPrice price=$total_products_wt}</td>
					</tr>
				{/if}
			{else}
				<tr class="cart_total_price">
					<td colspan="6">{l s='Total products:' mod='onepagecheckout'}</td>
					<td class="price" id="total_product">{displayPrice price=$total_products}</td>
				</tr>
			{/if}
			<tr class="cart_total_voucher" {if $total_discounts == 0}style="display: none;"{/if}>
				<td colspan="6">
				{if $use_taxes}
					{if $priceDisplay}
						{l s='Total vouchers' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax excl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}
					{else}
						{l s='Total vouchers' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax incl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}
					{/if}
				{else}
					{l s='Total vouchers:' mod='onepagecheckout'}
				{/if}
				</td>
				<td class="price-discount" id="total_discount">
				{if $use_taxes}
					{if $priceDisplay}
						{displayPrice price=$total_discounts_tax_exc}
					{else}
						{displayPrice price=$total_discounts}
					{/if}
				{else}
					{displayPrice price=$total_discounts_tax_exc}
				{/if}
				</td>
			</tr>
			<tr class="cart_total_voucher" {if $total_wrapping == 0}style="display: none;"{/if}>
				<td colspan="6">
				{if $use_taxes}
					{if $priceDisplay}
						{l s='Total gift-wrapping' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax excl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}
					{else}
						{l s='Total gift-wrapping' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax incl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}
					{/if}
				{else}
					{l s='Total gift-wrapping:' mod='onepagecheckout'}
				{/if}
				</td>
				<td class="price-discount" id="total_wrapping">
				{if $use_taxes}
					{if $priceDisplay}
						{displayPrice price=$total_wrapping_tax_exc}
					{else}
						{displayPrice price=$total_wrapping}
					{/if}
				{else}
					{displayPrice price=$total_wrapping_tax_exc}
				{/if}
				</td>
			</tr>
			{if $use_taxes}
				{if $priceDisplay}
					<tr class="cart_total_delivery" {if $shippingCost <= 0} style="display:none;"{/if}>
						<td colspan="6">{l s='Total shipping' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax excl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}</td>
						<td class="price" id="total_shipping">{displayPrice price=$shippingCostTaxExc}</td>
					</tr>
				{else}
					<tr class="cart_total_delivery"{if $shippingCost <= 0} style="display:none;"{/if}>
						<td colspan="6">{l s='Total shipping' mod='onepagecheckout'}{if isset($display_tax_label) && $display_tax_label} {l s='(tax incl.)' mod='onepagecheckout'}{/if}{l s=':' mod='onepagecheckout'}</td>
						<td class="price" id="total_shipping" >{displayPrice price=$shippingCost}</td>
					</tr>
				{/if}
			{else}
				<tr class="cart_total_delivery"{if $shippingCost <= 0} style="display:none;"{/if}>
					<td colspan="6">{l s='Total shipping:' mod='onepagecheckout'}</td>
					<td class="price" id="total_shipping" >{displayPrice price=$shippingCostTaxExc}</td>
				</tr>
			{/if}

			{if $use_taxes}
			<tr class="cart_total_price">
				<td colspan="6">
					{if isset($display_tax_label) && $display_tax_label}
						{l s='Total (tax excl.):' mod='onepagecheckout'}
					{else}
						{l s='Subtotal:' mod='onepagecheckout'}
					{/if}
				</td>
				<td class="price" id="total_price_without_tax">{displayPrice price=$total_price_without_tax}</td>
			</tr>
			<tr class="cart_total_tax">
				<td colspan="6">
					{if isset($display_tax_label) && $display_tax_label}
						{l s='Total tax:' mod='onepagecheckout'}
					{else}
						{l s='Estimated Sales Tax:' mod='onepagecheckout'}
					{/if}
				</td>
				<td class="price" id="total_tax">{displayPrice price=$total_tax}</td>
			</tr>
			<tr class="cart_total_price">
				<td colspan="6">
					{if isset($display_tax_label) && $display_tax_label}
						{l s='Total (tax incl.):' mod='onepagecheckout'}
					{else}
						{l s='Total:' mod='onepagecheckout'}
					{/if}
				</td>
				<td class="price" id="total_price">{displayPrice price=$total_price}</td>
			</tr>
			{else}
			<tr class="cart_total_price">
				<td colspan="6">{l s='Total:' mod='onepagecheckout'}</td>
				<td class="price" id="total_price">{displayPrice price=$total_price_without_tax}</td>
			</tr>
			{/if}
			<tr class="cart_free_shipping" {if $free_ship <= 0 || $isVirtualCart} style="display: none;" {/if}>
					<td colspan="6" style="white-space: normal;">{l s='Remaining amount to be added to your cart in order to obtain free shipping:' mod='onepagecheckout'}</td>
					<td id="free_shipping" class="price">{displayPrice price=$free_ship}</td>
				</tr>
		</tfoot>
		<tbody>
		{foreach from=$products item=product name=productLoop}
			{assign var='productId' value=$product.id_product}
			{assign var='productAttributeId' value=$product.id_product_attribute}
			{assign var='quantityDisplayed' value=0}
			{* Display the product line *}
			{include file="$tpl_dir./shopping-cart-product-line.tpl"}
			{* Then the customized datas ones*}
			{if isset($customizedDatas.$productId.$productAttributeId)}
				{foreach from=$customizedDatas.$productId.$productAttributeId key='id_customization' item='customization'}
					<tr id="product_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" class="alternate_item cart_item">
						<td colspan="5">
							{foreach from=$customization.datas key='type' item='datas'}
								{if $type == $CUSTOMIZE_FILE}
									<div class="customizationUploaded">
										<ul class="customizationUploaded">
											{foreach from=$datas item='picture'}<li><img src="{$pic_dir}{$picture.value}_small" alt="" class="customizationUploaded" /></li>{/foreach}
										</ul>
									</div>
								{elseif $type == $CUSTOMIZE_TEXTFIELD}
									<ul class="typedText">
										{foreach from=$datas item='textField' name='typedText'}<li>{if $textField.name}{$textField.name}{else}{l s='Text #' mod='onepagecheckout'}{$smarty.foreach.typedText.index+1}{/if}{l s=':' mod='onepagecheckout'} {$textField.value}</li>{/foreach}
									</ul>
								{/if}
							{/foreach}
						</td>
						<td class="cart_quantity">
							<div style="float:right">
								<a rel="nofollow" class="cart_quantity_delete" id="{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" href="{$link->getPageLink('cart.php', true)}?delete&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_customization={$id_customization}&token={$token_cart}"><img src="{$img_dir}icon/delete.gif" alt="{l s='Delete' mod='onepagecheckout'}" title="{l s='Delete this customization' mod='onepagecheckout'}" width="11" height="13" class="icon" /></a>
							</div>
							<div id="cart_quantity_button" style="float:left">
							<a rel="nofollow" class="cart_quantity_up" id="cart_quantity_up_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" href="{$link->getPageLink('cart.php', true)}?add&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_customization={$id_customization}&token={$token_cart}" title="{l s='Add' mod='onepagecheckout'}"><img src="{$img_dir}icon/quantity_up.gif" alt="{l s='Add' mod='onepagecheckout'}" width="14" height="9" /></a><br />
							{if $product.minimal_quantity < ($customization.quantity -$quantityDisplayed) OR $product.minimal_quantity <= 1}
							<a rel="nofollow" class="cart_quantity_down" id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" href="{$link->getPageLink('cart.php', true)}?add&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_customization={$id_customization}&op=down&token={$token_cart}" title="{l s='Subtract' mod='onepagecheckout'}">
								<img src="{$img_dir}icon/quantity_down.gif" alt="{l s='Subtract' mod='onepagecheckout'}" width="14" height="9" />
							</a>
							{else}
							<a class="cart_quantity_down" style="opacity: 0.3;" id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" href="#" title="{l s='Subtract' mod='onepagecheckout'}">
								<img src="{$img_dir}icon/quantity_down.gif" alt="{l s='Subtract' mod='onepagecheckout'}" width="14" height="9" />
							</a>
							{/if}
							</div>
							<input type="hidden" value="{$customization.quantity}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_hidden"/>
							<input size="2" type="text" value="{$customization.quantity}" class="cart_quantity_input" name="quantity_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}"/>
						</td>
						<td class="cart_total"></td>
					</tr>
					{assign var='quantityDisplayed' value=$quantityDisplayed+$customization.quantity}
				{/foreach}
				{* If it exists also some uncustomized products *}
				{if $product.quantity-$quantityDisplayed > 0}{include file="$tpl_dir./shopping-cart-product-line.tpl"}{/if}
			{/if}
		{/foreach}
		</tbody>
	{if sizeof($discounts)}
		<tbody>
		{foreach from=$discounts item=discount name=discountLoop}
			<tr class="cart_discount {if $smarty.foreach.discountLoop.last}last_item{elseif $smarty.foreach.discountLoop.first}first_item{else}item{/if}" id="cart_discount_{$discount.id_discount}">
				<td class="cart_discount_name" colspan="2">{$discount.name}</td>
				<td class="cart_discount_description" colspan="3">{$discount.description}</td>
				<td class="cart_discount_delete"><a href="{$opckt_script}?deleteDiscount={$discount.id_discount}" title="{l s='Delete' mod='onepagecheckout'}"><img src="{$img_dir}icon/delete.gif" alt="{l s='Delete' mod='onepagecheckout'}" class="icon" width="11" height="13" /></a></td>
				<td class="cart_discount_price"><span class="price-discount">
					{if $discount.value_real > 0}
						{if !$priceDisplay}{displayPrice price=$discount.value_real*-1}{else}{displayPrice price=$discount.value_tax_exc*-1}{/if}
					{/if}
				</span></td>
			</tr>
		{/foreach}
		</tbody>
	{/if}
	</table>
</div>

{if $logged}
{if $voucherAllowed}
{if $checkcustomer->id_default_group==2}
<div id="cart_voucher" class="table_block">
	{if isset($errors_discount) && $errors_discount}
		<ul class="error">
		{foreach from=$errors_discount key=k item=error}
			<li>{$error|escape:'htmlall':'UTF-8'}</li>
		{/foreach}
		</ul>
	{/if}
        <div id="opc_voucher_errors" class="error" style="display: none;"></div>
	<form action="{$opckt_script}" method="post" id="voucher">
		<fieldset>
			<h4>{l s='Vouchers' mod='onepagecheckout'}</h4>
			<p>
				<label for="discount_name">{l s='Code:' mod='onepagecheckout'}</label>
				<input type="text" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" />
			</p>
			<p class="submit"><input type="hidden" name="submitDiscount" /><input type="submit" name="submitAddDiscount" value="{l s='Add' mod='onepagecheckout'}" class="button" /></p>
		{if $displayVouchers}
			<h4>{l s='Take advantage of our offers:' mod='onepagecheckout'}</h4>
			<div id="display_cart_vouchers">
			{foreach from=$displayVouchers item=voucher}
				<span onclick="$('#discount_name').val('{$voucher.name}');return false;" class="voucher_name">{$voucher.name}</span> - {$voucher.description} <br />
			{/foreach}
			</div>
		{/if}
		</fieldset>
	</form>
</div>
{/if}
{/if}
{/if}


<div id="HOOK_SHOPPING_CART">{$HOOK_SHOPPING_CART}</div>

<p class="cart_navigation">
    <b>
	{if isset($onlyCartSummary)}<a href="{$link->getPageLink('order.php', true)}?step=1{if $back}&back={$back}{/if}" class="exclusive" title="{l s='Next'}">{l s='Next'} »</a>{/if}
        <a href="{if (isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, '{$opckt_script_name}')) || !isset($smarty.server.HTTP_REFERER)}{$link->getPageLink('index.php')}{else}{$smarty.server.HTTP_REFERER|escape:'htmlall':'UTF-8'|secureReferrer}{/if}" title="{l s='Continue shopping' mod='onepagecheckout'}">
            « {l s='Continue shopping' mod='onepagecheckout'}</a>{if !isset($onlyCartSummary)}  {l s='or fill in the form below to finish your order.' mod='onepagecheckout'}{/if}
    </b>
</p>
<p class="clear"></p>
<p class="cart_navigation_extra">
    <span id="HOOK_SHOPPING_CART_EXTRA">{$HOOK_SHOPPING_CART_EXTRA}</span>
</p>


{if isset($onlyCartSummary)}
<script type="text/javascript">
            // <![CDATA[
	var countries = new Array();
            idSelectedCountry = {if isset($guestInformations) && $guestInformations.id_state}{$guestInformations.id_state|intval}{else}{if ($def_state>0)}{$def_state}{else}false{/if}{/if};
            idSelectedCountry_invoice = {if isset($guestInformations) && isset($guestInformations.id_state_invoice)}{$guestInformations.id_state_invoice|intval}{else}{if ($def_state_invoice>0)}{$def_state_invoice}{else}false{/if}{/if};
                {if isset($countries)}
                    {foreach from=$countries item='country'}
                        {if isset($country.states) && $country.contains_states}
                                    countries[{$country.id_country|intval}] = new Array();
                            {foreach from=$country.states item='state' name='states'}
                                            countries[{$country.id_country|intval}].push({ldelim}'id' : '{$state.id_state}', 'name' : '{$state.name|escape:'htmlall':'UTF-8'}'{rdelim});
                            {/foreach}
                        {/if}
                    {/foreach}
                {/if}
            //]]>
</script>

	{if $isVirtualCart && $opc_config.virtual_no_delivery}
            <input type="hidden" name="id_country" id="id_country" value="{if isset($opc_config.online_country_id) && $opc_config.online_country_id > 0}{$opc_config.online_country_id}{else}8{/if}" /> {* 8=France, we choose some non-states country *}
          {else}
            <p class="required select" {if !isset($opc_config.country_delivery) || !$opc_config.country_delivery}style="display: none;"{/if}>
                <label for="id_country">{l s='Country' mod='onepagecheckout'}</label>
                <select name="id_country" id="id_country">
                    <option value="">-</option>
                    {foreach from=$countries item=v}
                        <option value="{$v.id_country}" {if (isset($guestInformations) AND $guestInformations.id_country == $v.id_country) OR ($def_country == $v.id_country ) OR (!isset($guestInformations) && ($def_country==0) && $sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'htmlall':'UTF-8'}</option>
                    {/foreach}
                </select>
            </p>

         {/if}

            <p class="required id_state select">
                <label for="id_state">{l s='State' mod='onepagecheckout'}</label>
                <select name="id_state" id="id_state">
                    <option value="">-</option>
                </select>
            </p>


{include file="order-carrier.tpl"}
{/if}



{/if}

Link to comment
Share on other sites

  • 1 month later...

Hi,

I was told by the opc module developer that I have to amend the controllers/ParentOrderController.php file.

In this file are the following lines :
self::$smarty->assign(array(
            'token_cart' => Tools::getToken(false),
            'isVirtualCart' => self::$cart->isVirtualCart(),

I guess that I have a line to add there in order to pass variable $checkcustomer to smarty array.

Would you know what line I should have to add ?

Think you in advance for your help.

Patrick

Link to comment
Share on other sites

Hi,

Thank you vekia.

As mentioned earlier my Prestahsop version is 1.4.7.0

In /controllers/ParentOrderController.php, is the here below code :

public function init()
{
parent::init();
$this->nbProducts = self::$cart->nbProducts();
}

Would you know what I would have to add here ?

Thank you again,

Patrick

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...