Jump to content

How to pass variable from "shopping-cart.tpl" to override class "cart.php" in prestashop 1.6


Recommended Posts

hello 

     I want to pass variable from shopping-cart.tpl page to cart.php...i want to make things like on order-summery page when + operation performs quantity up and refresh at the same , same way i want to perform when user select option from dorp down cart value varies.. as i mention in image

post-781913-0-35577900-1400506884_thumb.jpg

Link to comment
Share on other sites

you have to pass it with form in $_POST array

then in cart controller you can use Tools::getValue('name') where 'name' is an name of variable from $_POST array.

btw. prestashop 1.6 doesnt use cart.php anymore.

Link to comment
Share on other sites

you have to pass it with form in $_POST array

then in cart controller you can use Tools::getValue('name') where 'name' is an name of variable from $_POST array.

btw. prestashop 1.6 doesnt use cart.php anymore.

I have implemented another way in by following code it will works fine initially it will change data in cart -summry but when i refresh page it will get back to orignal value , I thing there is any method of saving changes to cart that I missed..?

 

 

$.ajax({

type: 'POST',
headers: { "cache-control": "no-cache" },
url: baseUri + '?rand=' + new Date().getTime(),
async: true,
cache: false,
dataType: 'json',
data: 'controller=cart'
+ '&ajax=true'
+ '&update=1'
// + '&getproductprice=true'
+ '&summary=true'
+ '&id_product={$product.id_product}'
+ '&whole_cart='+partial_payment
+ '&token='+static_token
+ '&allow_refresh=1',
success: function(jsonData)
{
alert("success");
if (jsonData.hasError)
{
var errors = '';
for(var error in jsonData.errors)
//IE6 bug fix
if(error !== 'indexOf')
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
alert(errors);
$('input[name=quantity_' + id + ']').val($('input[name=quantity_' + id + '_hidden]').val());
}
else
{
if (jsonData.refresh)
location.reload();
updateCartSummary(jsonData.summary);
if (window.ajaxCart !== undefined)
ajaxCart.updateCart(jsonData);
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
 
 
if (typeof(getCarrierListAndUpdate) !== 'undefined')
getCarrierListAndUpdate();
if (typeof(updatePaymentMethodsDisplay) !== 'undefined')
updatePaymentMethodsDisplay();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});

it will post data fine as well as get response well it will display change value aslo, but after refresh it will roll-back

Link to comment
Share on other sites

×
×
  • Create New...