I purchased a combo the module
Combo for Opencart
Installation and configuration is successful according to the manufacturer’s instructions.
The module does not process the transfer of a set Shopping Cart of goods.
Reason: shoppica2 does not use a built-in opencart:
index.php? route = checkout/cart /
and uses
index.php? route = tb/cartCallback
For this reason, do not work for third-party modules opencart, if you use shoppica2.
|
|
I see the solution:
Аdd to cart in this module works through a controller
/catalog/controller/checkout/cart.php
public function addCombo() {
$this->language->load('checkout/combo');
$json = array();
if (isset($this->request->post['combo_id'])) {
$combo_id = $this->request->post['combo_id'];
} else {
$combo_id = 0;
}
if (isset($this->request->post['combo_quantity'])) {
$combo_quantity = $this->request->post['combo_quantity'];
} else {
$combo_quantity = 1;
}
if (isset($this->request->post['option'])) {
$post_option = array_filter($this->request->post['option']);
} else {
$post_option = array();
}
$this->load->model('catalog/combo');
$ps = $this->model_catalog_combo->getComboProducts($combo_id);
$this->load->model('catalog/product');
$add_data = array();
foreach($ps as $p) {
$product_info = $this->model_catalog_product->getProduct($p['product_id']);
if ($product_info) {
$option = array();
$product_options = $this->model_catalog_product->getProductOptions($p['product_id']);
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($post_option[$product_option['product_option_id']])) {
$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
$json['error']['combo_id'] = $combo_id;
} else if (!empty($post_option[$product_option['product_option_id']])){
$option[$product_option['product_option_id']] = $post_option[$product_option['product_option_id']];
}
}
$add_data[] = array (
'product_id' => $p['product_id'],
'quantity' => $p['quantity'],
'option' => $option,
);
}
}
if (!$json) {
$quantity = 0;
foreach($add_data as $add)
{
$this->cart->add($add['product_id'], $combo_quantity * $add['quantity'], $add['option']);
$quantity += $combo_quantity * $add['quantity'];
}
$json['success'] = sprintf($this->language->get('text_success'), $quantity, $this->url->link('checkout/cart'));
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
// Totals
$this->load->model('setting/extension');
$total_data = array();
$total = 0;
$taxes = $this->cart->getTaxes();
// Display prices
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$sort_order = array();
$results = $this->model_setting_extension->getExtensions('total');
foreach ($results as $key => $value) {
$sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
}
array_multisort($sort_order, SORT_ASC, $results);
foreach ($results as $result) {
if ($this->config->get($result['code'] . '_status')) {
$this->load->model('total/' . $result['code']);
$this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
}
$sort_order = array();
foreach ($total_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $total_data);
}
}
$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
} else {
$json['error']['warning'] = $this->language->get('text_error');
$json['redirect'] = str_replace('&', '&', $this->url->link('product/combo', 'combo_id=' . $json['error']['combo_id']));
}
$this->response->setOutput(json_encode($json));
}
catalog\view\theme\shoppica2\template\module\combo.tpl
function addComboToCart(id) {
$('input[name=combo_id]').val(id);
$.ajax({
url: 'index.php?route=checkout/cart/addcombo',
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']['product_id'] != <?php echo $product_id?>) {
location = json['redirect'];
}
if (json['error']['option']) {
for (i in json['error']['option']) {
$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');
}
$('#notification').html('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.warning').fadeIn('slow');
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
if (json['success']) {
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.success').fadeIn('slow');
$('#cart-total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
});
}
but it does not work.
Looked like to put in a Shopping Cart in the product template
/catalog/view/theme/shoppica2/template/product/product.tpl
there use
url: ‘index.php?route=tb/cartCallback’,
The search led me to:
/tb_themes/shoppica2/catalog/controller/TbController.php
on line 62:
public function cartCallback()
{
$this->response->setOutput(json_encode($this->getCartContents()));
}
and
line 141
public function getCartContents()
{
. . . . .
My knowledge of php and json not allow the integration of the controller code, according to the structure of the data sent to the Shopping Cart
Need You help
-
This reply was modified 3944 days ago by maxun.
|
|
You can try to open catalog/view/theme/shoppica2/javascript/common.js.php and search for function addToCart(product_id) . Inside this function you could replace url: 'index.php?route=tb/cartCallback',
with url: 'index.php?route=checkout/cart/addcombo',
See if this works.
Regards,
ThemBurn team
|
|
it’s the first thing I try =)
Unfortunately this does not work.
|
|
Shoppica can’t just use the default cart controller, because it lacks certain features, which are needed to achieve some advanced functionality. It seems there is now way to make this plugin work without modifying its code, which is outside the free support this forum can offer.
Regards,
ThemeBurn team
|
|
have you solve this problem?
because i have this problem too..
|
|