0
Prestashop 1.4.9의 장바구니 모듈 인 ajax-cart.js에서 장바구니 ID를 검색하려고합니다.ajax-cart.js (prestashop 모듈)에서 장바구니 ID를 얻는 방법
쿠키에 저장되지 않았기 때문에 좋은 방법이 없습니다.
Prestashop 1.4.9의 장바구니 모듈 인 ajax-cart.js에서 장바구니 ID를 검색하려고합니다.ajax-cart.js (prestashop 모듈)에서 장바구니 ID를 얻는 방법
쿠키에 저장되지 않았기 때문에 좋은 방법이 없습니다.
현재 방문자에게서 장바구니 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에서이 값을 검색하면 방문자가 공개적으로 알 수 있습니다. 코드 및 지불 모듈의 안전성에 따라 문제가 될 수 있습니다.
실제로, 그것은 일을하지만, 성가시다. 어쨌든 고마워! 그것이 Prestashop 창시자에 의해 응답되었다는 것을 알기 좋은 :) –