【发布时间】:2014-04-28 16:09:20
【问题描述】:
点击此链接: Opencart: Adding Buy Now Button in Opencart Product Page
我在我的页面上添加了以下脚本:
$('#button-cart-buy').bind('click', function() {
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, information, .error').remove();
if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
}
}
if (json['error']['profile']) {
$('select[name="profile_id"]').after('<span class="error">' + json['error']['profile'] + '</span>');
}
}
if (json['success']) {window.location='<?php echo $this->url->link('checkout/checkout', '', 'SSL'); ?>';
}
}
});
});
但是,我想在添加相关产品之前清空购物车。
有谁知道怎么做或者有什么建议吗?
【问题讨论】:
标签: opencart