catalog/controller/api/cart.php
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
class ControllerApiCart extends Controller {
public function add() {
$this->load->language('api/cart');
$json = array();
if (!isset($this->session->data['api_id'])) {
$json['error']['warning'] = $this->language->get('error_permission');
} else {
if (isset($this->request->post['product'])) {
$this->cart->clear();
foreach ($this->request->post['product'] as $product) {
if (isset($product['option'])) {
$option = $product['option'];
} else {
$option = array();
}
$this->cart->add($product['product_id'], $product['quantity'], $option);
}
$json['success'] = $this->language->get('text_success');
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
} elseif (isset($this->request->post['product_id'])) {
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($this->request->post['product_id']);
if ($product_info) {
if (isset($this->request->post['quantity'])) {
$quantity = $this->request->post['quantity'];
} else {
$quantity = 1;
}
if (isset($this->request->post['option'])) {
$option = array_filter($this->request->post['option']);
} else {
$option = array();
}
$product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);
foreach ($product_options as $product_option) {
if ($product_option['required'] && empty($option[$product_option['product_option_id']])) {
$json['error']['option'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
}
}
if (!isset($json['error']['option'])) {
$this->cart->add($this->request->post['product_id'], $quantity, $option);
$json['success'] = $this->language->get('text_success');
后面还有 199 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
