ed0522 Posted November 19, 2015 Share Posted November 19, 2015 (edited) I'm developing a module and I want to submit a cart from a tpl file (cer.tpl). Below is the code of the form in cer.tpl.<form role="form" action="{$link->getPageLink('cart')|escape:'html':'UTF-8'}" method="post"><div class="form-group"><textarea class="form-control" rows="3" name="consulting_Info" id="consulting_Info"></textarea></div><p class="hidden"><input type="hidden" name="token" value="{$static_token}" /><input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" /><input type="hidden" name="add" value=1 /><input type="hidden" name="id_product_attribute" id="idCombination" value=1 /><input type="text" name="qty" id="quantity_wanted" class="text" value=1 /><input type="text" name="test" id="test" class="text" value="TestValue" /></p><div class="no-print"><button type="submit" name="Submit" class="exclusive"></span>{l s='Add to cart'}</span></button></div>And I use Tools::getValue method to get the value of 'consulting_Info' field. In cartController.phppublic function init(){parent::init();// Send noindex to avoid ghost carts by botsheader('X-Robots-Tag: noindex, nofollow', true);// Get page main parameters$this->id_product = (int)Tools::getValue('id_product', null);$this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa'));$this->customization_id = (int)Tools::getValue('id_customization');$this->qty = abs(Tools::getValue('qty', 1));$this->id_address_delivery = (int)Tools::getValue('id_address_delivery');$this->consulting_Info = (int)Tools::getValue('consulting_Info');$this->context->smarty->assign('consulting_Info', $consulting_Info);}Finally, I wrote {$consulting_Info} in shopping-cart.tpl, it showed the payment page, but it didn't show the value in onsulting_Info field. Edited November 19, 2015 by ed0522 (see edit history) Link to comment Share on other sites More sharing options...
kush4133 Posted November 19, 2015 Share Posted November 19, 2015 shopingcart.tpl {* * 2007-2014 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-2014 PrestaShop SA * @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'}{/capture} <h1 id="cart_title" class="page-heading">{l s='Shopping-cart summary'} {if !isset($empty) && !$PS_CATALOG_MODE} <span class="heading-counter">{l s='Your shopping cart contains:'} <span id="summary_products_quantity">{$productNumber} {if $productNumber == 1}{l s='product'}{else}{l s='products'}{/if}</span> </span> {/if} </h1> {if isset($account_created)} <p class="alert alert-success"> {l s='Your account has been created.'} </p> {/if} {assign var='current_step' value='summary'} {include file="$tpl_dir./order-steps.tpl"} {include file="$tpl_dir./errors.tpl"} {if isset($empty)} <p class="alert alert-warning">{l s='Your shopping cart is empty.'}</p> {elseif $PS_CATALOG_MODE} <p class="alert alert-warning">{l s='This store has not accepted your new order.'}</p> {else} <p style="display:none" id="emptyCartWarning" class="alert alert-warning">{l s='Your shopping cart is empty.'}</p> {if isset($lastProductAdded) AND $lastProductAdded} <div class="cart_last_product"> <div class="cart_last_product_header"> <div class="left">{l s='Last product added'}</div> </div> <a class="cart_last_product_img" href="{$link->getProductLink($lastProductAdded.id_product, $lastProductAdded.link_rewrite, $lastProductAdded.category, null, null, $lastProductAdded.id_shop)|escape:'html':'UTF-8'}"> <img src="{$link->getImageLink($lastProductAdded.link_rewrite, $lastProductAdded.id_image, 'small_default')|escape:'html':'UTF-8'}" alt="{$lastProductAdded.name|escape:'html':'UTF-8'}"/> </a> <div class="cart_last_product_content"> <p class="product-name"> <a href="{$link->getProductLink($lastProductAdded.id_product, $lastProductAdded.link_rewrite, $lastProductAdded.category, null, null, null, $lastProductAdded.id_product_attribute)|escape:'html':'UTF-8'}"> {$lastProductAdded.name|escape:'html':'UTF-8'} </a> </p> {if isset($lastProductAdded.attributes) && $lastProductAdded.attributes} <small> <a href="{$link->getProductLink($lastProductAdded.id_product, $lastProductAdded.link_rewrite, $lastProductAdded.category, null, null, null, $lastProductAdded.id_product_attribute)|escape:'html':'UTF-8'}"> {$lastProductAdded.attributes|escape:'html':'UTF-8'} </a> </small> {/if} </div> </div> {/if} {assign var='total_discounts_num' value="{if $total_discounts != 0}1{else}0{/if}"} {assign var='use_show_taxes' value="{if $use_taxes && $show_taxes}2{else}0{/if}"} {assign var='total_wrapping_taxes_num' value="{if $total_wrapping != 0}1{else}0{/if}"} {* eu-legal *} {hook h="displayBeforeShoppingCartBlock"} <div id="order-detail-content" class="table_block table-responsive"> <table id="cart_summary" class="table table-bordered {if $PS_STOCK_MANAGEMENT}stock-management-on{else}stock-management-off{/if}"> <thead> <tr> <th class="cart_product first_item">{l s='Product'}</th> <th class="cart_description item">{l s='Description'}</th> {if $PS_STOCK_MANAGEMENT} {assign var='col_span_subtotal' value='3'} <th class="cart_avail item">{l s='Avail.'}</th> {else} {assign var='col_span_subtotal' value='2'} {/if} <th class="cart_unit item">{l s='Unit price'}</th> <th class="cart_quantity item">{l s='Qty'}</th> <th class="cart_total item">{l s='Total'}</th> <th class="cart_delete last_item"> </th> </tr> </thead> <tfoot> {if $use_taxes} {if $priceDisplay} <tr class="cart_total_price"> <td rowspan="{3+$total_discounts_num+$use_show_taxes+$total_wrapping_taxes_num}" colspan="3" id="cart_voucher" class="cart_voucher"> {if $voucherAllowed} {if isset($errors_discount) && $errors_discount} <ul class="alert alert-danger"> {foreach $errors_discount as $k=>$error} <li>{$error|escape:'html':'UTF-8'}</li> {/foreach} </ul> {/if} <form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="voucher"> <fieldset> <h4>{l s='Vouchers'}</h4> <input type="text" class="discount_name form-control" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" /> <input type="hidden" name="submitDiscount" /> <button type="submit" name="submitAddDiscount" class="button btn btn-default button-small"><span>{l s='OK'}</span></button> </fieldset> </form> {if $displayVouchers} <p id="title" class="title-offers">{l s='Take advantage of our exclusive offers:'}</p> <div id="display_cart_vouchers"> {foreach $displayVouchers as $voucher} {if $voucher.code != ''}<span class="voucher_name" data-code="{$voucher.code|escape:'html':'UTF-8'}">{$voucher.code|escape:'html':'UTF-8'}</span> - {/if}{$voucher.name}<br /> {/foreach} </div> {/if} {/if} </td> <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total products (tax excl.)'}{else}{l s='Total products'}{/if}</td> <td colspan="2" class="price" id="total_product">{displayPrice price=$total_products}</td> </tr> {else} <tr class="cart_total_price"> <td rowspan="{3+$total_discounts_num+$use_show_taxes+$total_wrapping_taxes_num}" colspan="2" id="cart_voucher" class="cart_voucher"> {if $voucherAllowed} {if isset($errors_discount) && $errors_discount} <ul class="alert alert-danger"> {foreach $errors_discount as $k=>$error} <li>{$error|escape:'html':'UTF-8'}</li> {/foreach} </ul> {/if} <form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="voucher"> <fieldset> <h4>{l s='Vouchers'}</h4> <input type="text" class="discount_name form-control" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" /> <input type="hidden" name="submitDiscount" /> <button type="submit" name="submitAddDiscount" class="button btn btn-default button-small"><span>{l s='OK'}</span></button> </fieldset> </form> {if $displayVouchers} <p id="title" class="title-offers">{l s='Take advantage of our exclusive offers:'}</p> <div id="display_cart_vouchers"> {foreach $displayVouchers as $voucher} {if $voucher.code != ''}<span class="voucher_name" data-code="{$voucher.code|escape:'html':'UTF-8'}">{$voucher.code|escape:'html':'UTF-8'}</span> - {/if}{$voucher.name}<br /> {/foreach} </div> {/if} {/if} </td> <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total products (tax incl.)'}{else}{l s='Total products'}{/if}</td> <td colspan="2" class="price" id="total_product">{displayPrice price=$total_products_wt}</td> </tr> {/if} {else} <tr class="cart_total_price"> <td rowspan="{3+$total_discounts_num+$use_show_taxes+$total_wrapping_taxes_num}" colspan="2" id="cart_voucher" class="cart_voucher"> {if $voucherAllowed} {if isset($errors_discount) && $errors_discount} <ul class="alert alert-danger"> {foreach $errors_discount as $k=>$error} <li>{$error|escape:'html':'UTF-8'}</li> {/foreach} </ul> {/if} <form action="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}" method="post" id="voucher"> <fieldset> <h4>{l s='Vouchers'}</h4> <input type="text" class="discount_name form-control" id="discount_name" name="discount_name" value="{if isset($discount_name) && $discount_name}{$discount_name}{/if}" /> <input type="hidden" name="submitDiscount" /> <button type="submit" name="submitAddDiscount" class="button btn btn-default button-small"> <span>{l s='OK'}</span> </button> </fieldset> </form> {if $displayVouchers} <p id="title" class="title-offers">{l s='Take advantage of our exclusive offers:'}</p> <div id="display_cart_vouchers"> {foreach $displayVouchers as $voucher} {if $voucher.code != ''}<span class="voucher_name" data-code="{$voucher.code|escape:'html':'UTF-8'}">{$voucher.code|escape:'html':'UTF-8'}</span> - {/if}{$voucher.name}<br /> {/foreach} </div> {/if} {/if} </td> <td colspan="{$col_span_subtotal}" class="text-right">{l s='Total products'}</td> <td colspan="2" class="price" id="total_product">{displayPrice price=$total_products}</td> </tr> {/if} <tr{if $total_wrapping == 0} style="display: none;"{/if}> <td colspan="3" class="text-right"> {if $use_taxes} {if $display_tax_label}{l s='Total gift wrapping (tax incl.):'}{else}{l s='Total gift-wrapping cost:'}{/if} {else} {l s='Total gift-wrapping cost:'} {/if} </td> <td colspan="2" class="price-discount price" 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 $total_shipping_tax_exc <= 0 && !isset($virtualCart)} <tr class="cart_total_delivery" style="{if !isset($carrier->id) || is_null($carrier->id)}display:none;{/if}"> <td colspan="{$col_span_subtotal}" class="text-right">{l s='Shipping'}</td> <td colspan="2" class="price" id="total_shipping">{l s='Free Shipping!'}</td> </tr> {else} {if $use_taxes && $total_shipping_tax_exc != $total_shipping} {if $priceDisplay} <tr class="cart_total_delivery" {if $total_shipping_tax_exc <= 0} style="display:none;"{/if}> <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total shipping (tax excl.)'}{else}{l s='Total shipping'}{/if}</td> <td colspan="2" class="price" id="total_shipping">{displayPrice price=$total_shipping_tax_exc}</td> </tr> {else} <tr class="cart_total_delivery"{if $total_shipping <= 0} style="display:none;"{/if}> <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total shipping (tax incl.)'}{else}{l s='Total shipping'}{/if}</td> <td colspan="2" class="price" id="total_shipping" >{displayPrice price=$total_shipping}</td> </tr> {/if} {else} <tr class="cart_total_delivery"{if $total_shipping_tax_exc <= 0} style="display:none;"{/if}> <td colspan="{$col_span_subtotal}" class="text-right">{l s='Total shipping'}</td> <td colspan="2" class="price" id="total_shipping" >{displayPrice price=$total_shipping_tax_exc}</td> </tr> {/if} {/if} <tr class="cart_total_voucher" {if $total_discounts == 0}style="display:none"{/if}> <td colspan="{$col_span_subtotal}" class="text-right"> {if $display_tax_label} {if $use_taxes && $priceDisplay == 0} {l s='Total vouchers (tax incl.):'} {else} {l s='Total vouchers (tax excl.)'} {/if} {else} {l s='Total vouchers'} {/if} </td> <td colspan="2" class="price-discount price" id="total_discount"> {if $use_taxes && $priceDisplay == 0} {assign var='total_discounts_negative' value=$total_discounts * -1} {else} {assign var='total_discounts_negative' value=$total_discounts_tax_exc * -1} {/if} {displayPrice price=$total_discounts_negative} </td> </tr> {if $use_taxes && $show_taxes} <tr class="cart_total_price"> <td colspan="{$col_span_subtotal}" class="text-right">{if $display_tax_label}{l s='Total (tax excl.)'}{else}{l s='Total'}{/if}</td> <td colspan="2" class="price" id="total_price_without_tax">{displayPrice price=$total_price_without_tax}</td> </tr> <tr class="cart_total_tax"> <td colspan="{$col_span_subtotal}" class="text-right">{l s='Tax'}</td> <td colspan="2" class="price" id="total_tax">{displayPrice price=$total_tax}</td> </tr> {/if} <tr class="cart_total_price"> <td colspan="{$col_span_subtotal}" class="total_price_container text-right"> <span>{l s='Total'}</span> </td> {if $use_taxes} <td colspan="2" class="price" id="total_price_container"> <span id="total_price">{displayPrice price=$total_price}</span> </td> {else} <td colspan="2" class="price" id="total_price_container"> <span id="total_price">{displayPrice price=$total_price_without_tax}</span> </td> {/if} </tr> </tfoot> <tbody> {assign var='odd' value=0} {assign var='have_non_virtual_products' value=false} {foreach $products as $product} {if $product.is_virtual == 0} {assign var='have_non_virtual_products' value=true} {/if} {assign var='productId' value=$product.id_product} {assign var='productAttributeId' value=$product.id_product_attribute} {assign var='quantityDisplayed' value=0} {assign var='odd' value=($odd+1)%2} {assign var='ignoreProductLast' value=isset($customizedDatas.$productId.$productAttributeId) || count($gift_products)} {* Display the product line *} {include file="$tpl_dir./shopping-cart-product-line.tpl" productLast=$product@last productFirst=$product@first} {* Then the customized datas ones*} {if isset($customizedDatas.$productId.$productAttributeId)} {foreach $customizedDatas.$productId.$productAttributeId[$product.id_address_delivery] as $id_customization=>$customization} <tr id="product_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_{$product.id_address_delivery|intval}" class="product_customization_for_{$product.id_product}_{$product.id_product_attribute}_{$product.id_address_delivery|intval}{if $odd} odd{else} even{/if} customization alternate_item {if $product@last && $customization@last && !count($gift_products)}last_item{/if}"> <td></td> <td colspan="3"> {foreach $customization.datas as $type => $custom_data} {if $type == $CUSTOMIZE_FILE} <div class="customizationUploaded"> <ul class="customizationUploaded"> {foreach $custom_data as $picture} <li><img src="{$pic_dir}{$picture.value}_small" alt="" class="customizationUploaded" /></li> {/foreach} </ul> </div> {elseif $type == $CUSTOMIZE_TEXTFIELD} <ul class="typedText"> {foreach $custom_data as $textField} <li> {if $textField.name} {$textField.name} {else} {l s='Text #'}{$textField@index+1} {/if} : {$textField.value} </li> {/foreach} </ul> {/if} {/foreach} </td> <td class="cart_quantity" colspan="2"> {if isset($cannotModify) AND $cannotModify == 1} <span>{if $quantityDisplayed == 0 AND isset($customizedDatas.$productId.$productAttributeId)}{$customizedDatas.$productId.$productAttributeId|@count}{else}{$product.cart_quantity-$quantityDisplayed}{/if}</span> {else} <input type="hidden" value="{$customization.quantity}" name="quantity_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_{$product.id_address_delivery|intval}_hidden"/> <input type="text" value="{$customization.quantity}" class="cart_quantity_input form-control grey" name="quantity_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_{$product.id_address_delivery|intval}"/> <div class="cart_quantity_button clearfix"> {if $product.minimal_quantity < ($customization.quantity -$quantityDisplayed) OR $product.minimal_quantity <= 1} <a id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_{$product.id_address_delivery|intval}" class="cart_quantity_down btn btn-default button-minus" href="{$link->getPageLink('cart', true, NULL, "add=1&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_address_delivery={$product.id_address_delivery}&id_customization={$id_customization}&op=down&token={$token_cart}")|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Subtract'}"> <span><i class="fa fa-minus"></i></span> </a> {else} <a id="cart_quantity_down_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}" class="cart_quantity_down btn btn-default button-minus disabled" href="#" title="{l s='Subtract'}"> <span><i class="fa fa-minus"></i></span> </a> {/if} <a id="cart_quantity_up_{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_{$product.id_address_delivery|intval}" class="cart_quantity_up btn btn-default button-plus" href="{$link->getPageLink('cart', true, NULL, "add=1&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_address_delivery={$product.id_address_delivery}&id_customization={$id_customization}&token={$token_cart}")|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Add'}"> <span><i class="fa fa-plus"></i></span> </a> </div> {/if} </td> <td class="cart_delete"> {if isset($cannotModify) AND $cannotModify == 1} {else} <div> <a id="{$product.id_product}_{$product.id_product_attribute}_{$id_customization}_{$product.id_address_delivery|intval}" class="cart_quantity_delete" href="{$link->getPageLink('cart', true, NULL, "delete=1&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_customization={$id_customization}&id_address_delivery={$product.id_address_delivery}&token={$token_cart}")|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Delete'}"> <i class=" fa fa-trash"></i> </a> </div> {/if} </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" productLast=$product@last productFirst=$product@first}{/if} {/if} {/foreach} {assign var='last_was_odd' value=$product@iteration%2} {foreach $gift_products as $product} {assign var='productId' value=$product.id_product} {assign var='productAttributeId' value=$product.id_product_attribute} {assign var='quantityDisplayed' value=0} {assign var='odd' value=($product@iteration+$last_was_odd)%2} {assign var='ignoreProductLast' value=isset($customizedDatas.$productId.$productAttributeId)} {assign var='cannotModify' value=1} {* Display the gift product line *} {include file="$tpl_dir./shopping-cart-product-line.tpl" productLast=$product@last productFirst=$product@first} {/foreach} </tbody> {if sizeof($discounts)} <tbody> {foreach $discounts as $discount} <tr class="cart_discount {if $discount@last}last_item{elseif $discount@first}first_item{else}item{/if}" id="cart_discount_{$discount.id_discount}"> <td class="cart_discount_name" colspan="{if $PS_STOCK_MANAGEMENT}3{else}2{/if}">{$discount.name}</td> <td class="cart_discount_price"> <span class="price-discount"> {if !$priceDisplay}{displayPrice price=$discount.value_real*-1}{else}{displayPrice price=$discount.value_tax_exc*-1}{/if} </span> </td> <td class="cart_discount_delete">1</td> <td class="cart_discount_price"> <span class="price-discount price">{if !$priceDisplay}{displayPrice price=$discount.value_real*-1}{else}{displayPrice price=$discount.value_tax_exc*-1}{/if}</span> </td> <td class="price_discount_del text-center"> {if strlen($discount.code)} <a href="{if $opc}{$link->getPageLink('order-opc', true)}{else}{$link->getPageLink('order', true)}{/if}?deleteDiscount={$discount.id_discount}" class="price_discount_delete" title="{l s='Delete'}"> <i class="fa fa-trash"></i> </a> {/if} </td> </tr> {/foreach} </tbody> {/if} </table> </div> <!-- end order-detail-content --> {if $show_option_allow_separate_package} <p> <input type="checkbox" name="allow_seperated_package" id="allow_seperated_package" {if $cart->allow_seperated_package}checked="checked"{/if} autocomplete="off"/> <label for="allow_seperated_package">{l s='Send available products first'}</label> </p> {/if} {* Define the style if it doesn't exist in the PrestaShop version*} {* Will be deleted for 1.5 version and more *} {if !isset($addresses_style)} {$addresses_style.company = 'address_company'} {$addresses_style.vat_number = 'address_company'} {$addresses_style.firstname = 'address_name'} {$addresses_style.lastname = 'address_name'} {$addresses_style.address1 = 'address_address1'} {$addresses_style.address2 = 'address_address2'} {$addresses_style.city = 'address_city'} {$addresses_style.country = 'address_country'} {$addresses_style.phone = 'address_phone'} {$addresses_style.phone_mobile = 'address_phone_mobile'} {$addresses_style.alias = 'address_title'} {/if} {if ((!empty($delivery_option) AND !isset($virtualCart)) OR $delivery->id OR $invoice->id) AND !$opc} <div class="order_delivery clearfix row"> {if !isset($formattedAddresses) || (count($formattedAddresses.invoice) == 0 && count($formattedAddresses.delivery) == 0) || (count($formattedAddresses.invoice.formated) == 0 && count($formattedAddresses.delivery.formated) == 0)} {if $delivery->id} <div class="col-xs-12 col-sm-6"{if !$have_non_virtual_products} style="display: none;"{/if}> <ul id="delivery_address" class="address item box"> <li><h3 class="page-subheading">{l s='Delivery address'} <span class="address_alias">({$delivery->alias})</span></h3></li> {if $delivery->company}<li class="address_company">{$delivery->company|escape:'html':'UTF-8'}</li>{/if} <li class="address_name">{$delivery->firstname|escape:'html':'UTF-8'} {$delivery->lastname|escape:'html':'UTF-8'}</li> <li class="address_address1">{$delivery->address1|escape:'html':'UTF-8'}</li> {if $delivery->address2}<li class="address_address2">{$delivery->address2|escape:'html':'UTF-8'}</li>{/if} <li class="address_city">{$delivery->postcode|escape:'html':'UTF-8'} {$delivery->city|escape:'html':'UTF-8'}</li> <li class="address_country">{$delivery->country|escape:'html':'UTF-8'} {if $delivery_state}({$delivery_state|escape:'html':'UTF-8'}){/if}</li> </ul> </div> {/if} {if $invoice->id} <div class="col-xs-12 col-sm-6"> <ul id="invoice_address" class="address alternate_item box"> <li><h3 class="page-subheading">{l s='Invoice address'} <span class="address_alias">({$invoice->alias})</span></h3></li> {if $invoice->company}<li class="address_company">{$invoice->company|escape:'html':'UTF-8'}</li>{/if} <li class="address_name">{$invoice->firstname|escape:'html':'UTF-8'} {$invoice->lastname|escape:'html':'UTF-8'}</li> <li class="address_address1">{$invoice->address1|escape:'html':'UTF-8'}</li> {if $invoice->address2}<li class="address_address2">{$invoice->address2|escape:'html':'UTF-8'}</li>{/if} <li class="address_city">{$invoice->postcode|escape:'html':'UTF-8'} {$invoice->city|escape:'html':'UTF-8'}</li> <li class="address_country">{$invoice->country|escape:'html':'UTF-8'} {if $invoice_state}({$invoice_state|escape:'html':'UTF-8'}){/if}</li> </ul> </div> {/if} {else} {foreach from=$formattedAddresses key=k item=address} <div class="col-xs-12 col-sm-6"{if $k == 'delivery' && !$have_non_virtual_products} style="display: none;"{/if}> <ul class="address {if $address@last}last_item{elseif $address@first}first_item{/if} {if $address@index % 2}alternate_item{else}item{/if} box"> <li> <h3 class="page-subheading"> {if $k eq 'invoice'} {l s='Invoice address'} {elseif $k eq 'delivery' && $delivery->id} {l s='Delivery address'} {/if} {if isset($address.object.alias)} <span class="address_alias">({$address.object.alias})</span> {/if} </h3> </li> {foreach $address.ordered as $pattern} {assign var=addressKey value=" "|explode:$pattern} {assign var=addedli value=false} {foreach from=$addressKey item=key name=foo} {$key_str = $key|regex_replace:AddressFormat::_CLEANING_REGEX_:""} {if isset($address.formated[$key_str]) && !empty($address.formated[$key_str])} {if (!$addedli)} {$addedli = true} <li><span class="{if isset($addresses_style[$key_str])}{$addresses_style[$key_str]}{/if}"> {/if} {$address.formated[$key_str]|escape:'html':'UTF-8'} {/if} {if ($smarty.foreach.foo.last && $addedli)} </span></li> {/if} {/foreach} {/foreach} </ul> </div> {/foreach} {/if} </div> {/if} <div id="HOOK_SHOPPING_CART">{$HOOK_SHOPPING_CART}</div> <p class="cart_navigation clearfix"> {if !$opc} <a href="{if $back}{$link->getPageLink('order', true, NULL, 'step=1&back={$back}')|escape:'html':'UTF-8'}{else}{$link->getPageLink('order', true, NULL, 'step=1')|escape:'html':'UTF-8'}{/if}" class="btnsns pull-right" title="{l s='Proceed to checkout'}"> <span>{l s='Proceed to checkout'}<i class="fa fa-chevron-right right"></i></span> </a> {/if} <a href="{if (isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, 'order.php')) || isset($smarty.server.HTTP_REFERER) && strstr($smarty.server.HTTP_REFERER, 'order-opc') || !isset($smarty.server.HTTP_REFERER)}{$link->getPageLink('index')}{else}{$smarty.server.HTTP_REFERER|escape:'html':'UTF-8'|secureReferrer}{/if}" class="btnsns" title="{l s='Continue shopping'}"> <i class="fa fa-chevron-left"></i>{l s='Continue shopping'} </a> </p> {if !empty($HOOK_SHOPPING_CART_EXTRA)} <div class="clear"></div> <div class="cart_navigation_extra"> <div id="HOOK_SHOPPING_CART_EXTRA">{$HOOK_SHOPPING_CART_EXTRA}</div> </div> {/if} {strip} {addJsDef currencySign=$currencySign|html_entity_decode:2:"UTF-8"} {addJsDef currencyRate=$currencyRate|floatval} {addJsDef currencyFormat=$currencyFormat|intval} {addJsDef currencyBlank=$currencyBlank|intval} {addJsDef deliveryAddress=$cart->id_address_delivery|intval} {addJsDefL name=txtProduct}{l s='product' js=1}{/addJsDefL} {addJsDefL name=txtProducts}{l s='products' js=1}{/addJsDefL} {/strip} {/if} Link to comment Share on other sites More sharing options...
kush4133 Posted November 19, 2015 Share Posted November 19, 2015 CartController.php <?php /* * 2007-2015 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 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/osl-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-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class CartControllerCore extends FrontController { public $php_self = 'cart'; protected $id_product; protected $id_product_attribute; protected $id_address_delivery; protected $customization_id; protected $qty; public $ssl = true; protected $ajax_refresh = false; /** * This is not a public page, so the canonical redirection is disabled * * @param string $canonicalURL */ public function canonicalRedirection($canonicalURL = '') { } /** * Initialize cart controller * @see FrontController::init() */ public function init() { parent::init(); // Send noindex to avoid ghost carts by bots header('X-Robots-Tag: noindex, nofollow', true); // Get page main parameters $this->id_product = (int)Tools::getValue('id_product', null); $this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa')); $this->customization_id = (int)Tools::getValue('id_customization'); $this->qty = abs(Tools::getValue('qty', 1)); $this->id_address_delivery = (int)Tools::getValue('id_address_delivery'); } public function postProcess() { // Update the cart ONLY if $this->cookies are available, in order to avoid ghost carts created by bots if ($this->context->cookie->exists() && !$this->errors && !($this->context->customer->isLogged() && !$this->isTokenValid())) { if (Tools::getIsset('add') || Tools::getIsset('update')) { $this->processChangeProductInCart(); } elseif (Tools::getIsset('delete')) { $this->processDeleteProductInCart(); } elseif (Tools::getIsset('changeAddressDelivery')) { $this->processChangeProductAddressDelivery(); } elseif (Tools::getIsset('allowSeperatedPackage')) { $this->processAllowSeperatedPackage(); } elseif (Tools::getIsset('duplicate')) { $this->processDuplicateProduct(); } // Make redirection if (!$this->errors && !$this->ajax) { $queryString = Tools::safeOutput(Tools::getValue('query', null)); if ($queryString && !Configuration::get('PS_CART_REDIRECT')) { Tools::redirect('index.php?controller=search&search='.$queryString); } // Redirect to previous page if (isset($_SERVER['HTTP_REFERER'])) { if (isset($regs[3]) && !Configuration::get('PS_CART_REDIRECT')) { Tools::redirect($_SERVER['HTTP_REFERER']); } } Tools::redirect('index.php?controller=order&'.(isset($this->id_product) ? 'ipa='.$this->id_product : '')); } } elseif (!$this->isTokenValid()) { Tools::redirect('index.php'); } } /** * This process delete a product from the cart */ protected function processDeleteProductInCart() { $customization_product = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'customization` WHERE `id_cart` = '.(int)$this->context->cart->id.' AND `id_product` = '.(int)$this->id_product.' AND `id_customization` != '.(int)$this->customization_id); if (count($customization_product)) { $product = new Product((int)$this->id_product); if ($this->id_product_attribute > 0) { $minimal_quantity = (int)Attribute::getAttributeMinimalQty($this->id_product_attribute); } else { $minimal_quantity = (int)$product->minimal_quantity; } $total_quantity = 0; foreach ($customization_product as $custom) { $total_quantity += $custom['quantity']; } if ($total_quantity < $minimal_quantity) { $this->ajaxDie(Tools::jsonEncode(array( 'hasError' => true, 'errors' => array(sprintf(Tools::displayError('You must add %d minimum quantity', !Tools::getValue('ajax')), $minimal_quantity)), ))); } } if ($this->context->cart->deleteProduct($this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery)) { Hook::exec('actionAfterDeleteProductInCart', array( 'id_cart' => (int)$this->context->cart->id, 'id_product' => (int)$this->id_product, 'id_product_attribute' => (int)$this->id_product_attribute, 'customization_id' => (int)$this->customization_id, 'id_address_delivery' => (int)$this->id_address_delivery )); if (!Cart::getNbProducts((int)$this->context->cart->id)) { $this->context->cart->setDeliveryOption(null); $this->context->cart->gift = 0; $this->context->cart->gift_message = ''; $this->context->cart->update(); } } $removed = CartRule::autoRemoveFromCart(); CartRule::autoAddToCart(); if (count($removed) && (int)Tools::getValue('allow_refresh')) { $this->ajax_refresh = true; } } protected function processChangeProductAddressDelivery() { if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) { return; } $old_id_address_delivery = (int)Tools::getValue('old_id_address_delivery'); $new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery'); if (!count(Carrier::getAvailableCarrierList(new Product($this->id_product), null, $new_id_address_delivery))) { $this->ajaxDie(Tools::jsonEncode(array( 'hasErrors' => true, 'error' => Tools::displayError('It is not possible to deliver this product to the selected address.', false), ))); } $this->context->cart->setProductAddressDelivery( $this->id_product, $this->id_product_attribute, $old_id_address_delivery, $new_id_address_delivery); } protected function processAllowSeperatedPackage() { if (!Configuration::get('PS_SHIP_WHEN_AVAILABLE')) { return; } if (Tools::getValue('value') === false) { $this->ajaxDie('{"error":true, "error_message": "No value setted"}'); } $this->context->cart->allow_seperated_package = (bool)Tools::getValue('value'); $this->context->cart->update(); $this->ajaxDie('{"error":false}'); } protected function processDuplicateProduct() { if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) { return; } if (!$this->context->cart->duplicateProduct( $this->id_product, $this->id_product_attribute, $this->id_address_delivery, (int)Tools::getValue('new_id_address_delivery') )) { //$error_message = $this->l('Error durring product duplication'); // For the moment no translations $error_message = 'Error durring product duplication'; } } /** * This process add or update a product in the cart */ protected function processChangeProductInCart() { $mode = (Tools::getIsset('update') && $this->id_product) ? 'update' : 'add'; if ($this->qty == 0) { $this->errors[] = Tools::displayError('Null quantity.', !Tools::getValue('ajax')); } elseif (!$this->id_product) { $this->errors[] = Tools::displayError('Product not found', !Tools::getValue('ajax')); } $product = new Product($this->id_product, true, $this->context->language->id); if (!$product->id || !$product->active || !$product->checkAccess($this->context->cart->id_customer)) { $this->errors[] = Tools::displayError('This product is no longer available.', !Tools::getValue('ajax')); return; } $qty_to_check = $this->qty; $cart_products = $this->context->cart->getProducts(); if (is_array($cart_products)) { foreach ($cart_products as $cart_product) { if ((!isset($this->id_product_attribute) || $cart_product['id_product_attribute'] == $this->id_product_attribute) && (isset($this->id_product) && $cart_product['id_product'] == $this->id_product)) { $qty_to_check = $cart_product['cart_quantity']; if (Tools::getValue('op', 'up') == 'down') { $qty_to_check -= $this->qty; } else { $qty_to_check += $this->qty; } break; } } } // Check product quantity availability if ($this->id_product_attribute) { if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } } elseif ($product->hasAttributes()) { $minimumQuantity = ($product->out_of_stock == 2) ? !Configuration::get('PS_ORDER_OUT_OF_STOCK') : !$product->out_of_stock; $this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimumQuantity); // @todo do something better than a redirect admin !! if (!$this->id_product_attribute) { Tools::redirectAdmin($this->context->link->getProductLink($product)); } elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } } elseif (!$product->checkQty($qty_to_check)) { $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } // If no errors, process product addition if (!$this->errors && $mode == 'add') { // Add cart if no cart found if (!$this->context->cart->id) { if (Context::getContext()->cookie->id_guest) { $guest = new Guest(Context::getContext()->cookie->id_guest); $this->context->cart->mobile_theme = $guest->mobile_theme; } $this->context->cart->add(); if ($this->context->cart->id) { $this->context->cookie->id_cart = (int)$this->context->cart->id; } } // Check customizable fields if (!$product->hasAllRequiredCustomizableFields() && !$this->customization_id) { $this->errors[] = Tools::displayError('Please fill in all of the required fields, and then save your customizations.', !Tools::getValue('ajax')); } if (!$this->errors) { $cart_rules = $this->context->cart->getCartRules(); $update_quantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'), $this->id_address_delivery); if ($update_quantity < 0) { // If product has attribute, minimal quantity is set with minimal quantity of attribute $minimal_quantity = ($this->id_product_attribute) ? Attribute::getAttributeMinimalQty($this->id_product_attribute) : $product->minimal_quantity; $this->errors[] = sprintf(Tools::displayError('You must add %d minimum quantity', !Tools::getValue('ajax')), $minimal_quantity); } elseif (!$update_quantity) { $this->errors[] = Tools::displayError('You already have the maximum quantity available for this product.', !Tools::getValue('ajax')); } elseif ((int)Tools::getValue('allow_refresh')) { // If the cart rules has changed, we need to refresh the whole cart $cart_rules2 = $this->context->cart->getCartRules(); if (count($cart_rules2) != count($cart_rules)) { $this->ajax_refresh = true; } else { $rule_list = array(); foreach ($cart_rules2 as $rule) { $rule_list[] = $rule['id_cart_rule']; } foreach ($cart_rules as $rule) { if (!in_array($rule['id_cart_rule'], $rule_list)) { $this->ajax_refresh = true; break; } } } } } } $removed = CartRule::autoRemoveFromCart(); CartRule::autoAddToCart(); if (count($removed) && (int)Tools::getValue('allow_refresh')) { $this->ajax_refresh = true; } } /** * Remove discounts on cart * * @deprecated 1.5.3.0 */ protected function processRemoveDiscounts() { Tools::displayAsDeprecated(); $this->errors = array_merge($this->errors, CartRule::autoRemoveFromCart()); } /** * @see FrontController::initContent() */ public function initContent() { $this->setTemplate(_PS_THEME_DIR_.'errors.tpl'); if (!$this->ajax) { parent::initContent(); } } /** * Display ajax content (this function is called instead of classic display, in ajax mode) */ public function displayAjax() { if ($this->errors) { $this->ajaxDie(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors))); } if ($this->ajax_refresh) { $this->ajaxDie(Tools::jsonEncode(array('refresh' => true))); } // write cookie if can't on destruct $this->context->cookie->write(); if (Tools::getIsset('summary')) { $result = array(); if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { $groups = (Validate::isLoadedObject($this->context->customer)) ? $this->context->customer->getGroups() : array(1); if ($this->context->cart->id_address_delivery) { $deliveryAddress = new Address($this->context->cart->id_address_delivery); } $id_country = (isset($deliveryAddress) && $deliveryAddress->id) ? (int)$deliveryAddress->id_country : (int)Tools::getCountry(); Cart::addExtraCarriers($result); } $result['summary'] = $this->context->cart->getSummaryDetails(null, true); $result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true); $result['HOOK_SHOPPING_CART'] = Hook::exec('displayShoppingCartFooter', $result['summary']); $result['HOOK_SHOPPING_CART_EXTRA'] = Hook::exec('displayShoppingCart', $result['summary']); foreach ($result['summary']['products'] as $key => &$product) { $product['quantity_without_customization'] = $product['quantity']; if ($result['customizedDatas'] && isset($result['customizedDatas'][(int)$product['id_product']][(int)$product['id_product_attribute']])) { foreach ($result['customizedDatas'][(int)$product['id_product']][(int)$product['id_product_attribute']] as $addresses) { foreach ($addresses as $customization) { $product['quantity_without_customization'] -= (int)$customization['quantity']; } } } } if ($result['customizedDatas']) { Product::addCustomizationPrice($result['summary']['products'], $result['customizedDatas']); } $json = ''; Hook::exec('actionCartListOverride', array('summary' => $result, 'json' => &$json)); $this->ajaxDie(Tools::jsonEncode(array_merge($result, (array)Tools::jsonDecode($json, true)))); } // @todo create a hook elseif (file_exists(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php')) { require_once(_PS_MODULE_DIR_.'/blockcart/blockcart-ajax.php'); } } } Link to comment Share on other sites More sharing options...
ed0522 Posted November 19, 2015 Author Share Posted November 19, 2015 I just pasted part of the code. What did you mean by showing me the whole code? I don't know why, it seems that the $this->context object doesn't work in my situation. Link to comment Share on other sites More sharing options...
kush4133 Posted November 19, 2015 Share Posted November 19, 2015 try this code. if still you don't get the solution then go to module. open cart block and configure it. Link to comment Share on other sites More sharing options...
ed0522 Posted November 19, 2015 Author Share Posted November 19, 2015 OK, thank you. I will have a try. It's really kind of you. Link to comment Share on other sites More sharing options...
kush4133 Posted November 19, 2015 Share Posted November 19, 2015 i gave you whole code because you have to try my code and see what effect you get. just try from module. you will get the solution. tell me what happens afterwards. Link to comment Share on other sites More sharing options...
ed0522 Posted November 19, 2015 Author Share Posted November 19, 2015 (edited) There are 2 errors Product not found This product is no longer availaThere are 2 errors Edited November 19, 2015 by ed0522 (see edit history) Link to comment Share on other sites More sharing options...
ed0522 Posted November 19, 2015 Author Share Posted November 19, 2015 (edited) May be I can describe my question into how to submit a new field or add a new cart in a custom tpl file. You know, by default, we add a cart in product. tpl. Now I created a cer.tpl in a custom module and I want to add a cart in this file. Now the page can jump to the payment page. But it doesn't show the value of variable. Edited November 19, 2015 by ed0522 (see edit history) Link to comment Share on other sites More sharing options...
kush4133 Posted November 20, 2015 Share Posted November 20, 2015 can you please send me the link of your website? Link to comment Share on other sites More sharing options...
ed0522 Posted November 20, 2015 Author Share Posted November 20, 2015 sorry, i don't upload my website to the server. But I can show you more info. This is the link of the custom page. It's a tpl file in a custom module. http://localhost/prestashop/en/index.php?fc=module&module=myregister&controller=cer I won't show you the screenshot for it's not english. What I want is to submit a form to cart in this custom page. Link to comment Share on other sites More sharing options...
ed0522 Posted November 20, 2015 Author Share Posted November 20, 2015 (edited) If you add a field in the product.tpl, and use Tools::getValue() in cartController to get the value or you use $_POST[] mthod. I can't receive the value by using the both way. It seems that these methods don't work. But it shows mistakes which means that the code is compiled. Edited November 20, 2015 by ed0522 (see edit history) Link to comment Share on other sites More sharing options...
kush4133 Posted December 10, 2015 Share Posted December 10, 2015 hi.... did you got the solution of your problem? Link to comment Share on other sites More sharing options...
kush4133 Posted December 10, 2015 Share Posted December 10, 2015 i am talking about shopping cart. Link to comment Share on other sites More sharing options...
ashishpaceinfonet Posted December 25, 2015 Share Posted December 25, 2015 How to display hook content in custom php file. example. i have one php file test.php i want to dispay sidebar on that page. So one prestashop hook was displayTopColumn How i use it in custom php file Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now