2013-06-19 7 views

답변

3

현재 방문자에게서 장바구니 ID를 검색하는 방법은 여러 가지가 있지만 가장 쉬운 방법은 컨텍스트를 사용하는 것입니다.

1 단계 :

$.ajax({ 
    type: 'GET', 
    url: baseDir + 'modules/blockcart/ajax.php' + '?retrieve_cart_id=1', 
    success: function(result_cart_id) 
    { 
     alert(result_cart_id); 
     /* my_id_cart = parseInt(result_cart_id); Uncomment this line to store the value into a JS variable */ 
    } 
}); 

2 단계 : 파일 이름 ajax.php을 만들기 열기 /modules/blockcart/ajax-cart.js 및 아래 추가

$(document).ready(function(){ 

를 찾아 in/modules/blockcart/

내부 코드는 다음과 같습니다.

<?php 

include(dirname(__FILE__).'/../../config/config.inc.php'); 
include(dirname(__FILE__).'/../../init.php'); 

$context = Context::getContext(); 
if (Tools::getValue('retrieve_cart_id') == 1) 
    echo isset($context->cookie->id_cart) ? (int)$context->cookie->id_cart : 0; 

그게 전부 야!

Javascript에서이 값을 검색하면 방문자가 공개적으로 알 수 있습니다. 코드 및 지불 모듈의 안전성에 따라 문제가 될 수 있습니다.

+0

실제로, 그것은 일을하지만, 성가시다. 어쨌든 고마워! 그것이 Prestashop 창시자에 의해 응답되었다는 것을 알기 좋은 :) –

관련 문제