Skip to content

Commit

Permalink
分类页面,侧栏子分类只显示status为enable的分类
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed May 7, 2018
1 parent 5850337 commit 458f469
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/appfront/theme/base/front/checkout/cart/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,5 @@
<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['changeCartInfo'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>
<?= Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) ?>
<?php // Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) // 这个改成服务端发送加入购物车数据,而不是js传递的方式 ?>

2 changes: 1 addition & 1 deletion app/apphtml5/theme/base/html5/checkout/cart/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,4 @@
<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['changeCartInfo'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>
<?= Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) ?>
<?php // Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) // 这个改成服务端发送加入购物车数据,而不是js传递的方式 ?>
2 changes: 1 addition & 1 deletion services/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ protected function actionAddProductToCart($item)
}
$item['custom_option_sku'] = $custom_option_sku;
}

}
$item['sku'] = $product['sku'];
$item['qty'] = $this->getCartQty($product['package_number'], $item['qty']);

// 检查产品满足加入购物车的条件
Expand Down
37 changes: 36 additions & 1 deletion services/cart/QuoteItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function init(){
* 'product_id' => 22222,
* 'custom_option_sku' => red-xxl,
* 'qty' => 22,
* 'sku' => 'xxxx',
* ];
* 将某个产品加入到购物车中。在添加到cart_item表后,更新
* 购物车中产品的总数。
Expand Down Expand Up @@ -86,6 +87,33 @@ public function addItem($item)
// 重新计算购物车的数量,并写入sales_flat_cart表存储
Yii::$service->cart->quote->computeCartInfo();
}
$his->sendTraceAddToCartInfoByApi($item);

}
/**
* @property $item | Array, example:
* $item = [
* 'product_id' => 22222,
* 'custom_option_sku' => red-xxl,
* 'qty' => 22,
* 'sku' => 'xxxx',
* ];
* 将加入购物车的操作,加入trace
*/
public function sendTraceAddToCartInfoByApi($item){
if (Yii::$service->page->trace->traceJsEnable) {
$product_price_arr = Yii::$service->product->price->getCartPriceByProductId($item['product_id'], $item['qty'], $item['custom_option_sku'], 2);
$base_product_price = isset($product_price_arr['base_price']) ? $product_price_arr['base_price'] : 0;
$price = $base_product_price * $item['qty'];
$trace_cart_info = [
[
'sku' => $item['sku'],
'price' => $price,
'qty' => $item['qty'],
]
];
Yii::$service->page->trace->sendTraceAddToCartInfoByApi($trace_cart_info);
}
}

/**
Expand Down Expand Up @@ -295,7 +323,14 @@ public function addOneItem($item_id)
$one->save();
// 重新计算购物车的数量
Yii::$service->cart->quote->computeCartInfo();

$item = [
'product_id' => $product_id,
'custom_option_sku' => $one['custom_option_sku'],
'qty' => $changeQty,
'sku' => $product['sku'],
];
// 购物车数据加1
$his->sendTraceAddToCartInfoByApi($item);
return true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions services/category/CategoryMongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ protected function getOneLevelCateChild($category)
$url_key = $category['url_key'];
$cate = $this->_categoryModel->find()->asArray()->where([
'parent_id' => $_id,
'status' => $this->getCategoryEnableStatus(),
])->all();
if (is_array($cate) && !empty($cate)) {
foreach ($cate as $one) {
Expand Down Expand Up @@ -414,6 +415,7 @@ protected function getAllParentCate($allParent)
if ($parent_id) {
$cate = $this->_categoryModel->find()->asArray()->where([
'parent_id' => $parent_id,
'status' => $this->getCategoryEnableStatus(),
])->all();
//var_dump($cate);
//echo '$$$$$$$$$$';
Expand Down Expand Up @@ -453,6 +455,7 @@ protected function getChildCate($category_id)
//echo $category_id;
$data = $this->_categoryModel->find()->asArray()->where([
'parent_id' => $category_id,
'status' => $this->getCategoryEnableStatus(),
])->all();
$arr = [];
if (is_array($data) && !empty($data)) {
Expand Down
13 changes: 12 additions & 1 deletion services/page/Trace.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Trace extends Service

const LOGIN_EMAIL = 'login_email';
const REGISTER_EMAIL = 'register_email';
const CART = 'cart';
const PAYMENT_PENDING_ORDER = 'payment_pending_order';
const PAYMENT_SUCCESS_ORDER = 'payment_success_order';

Expand Down Expand Up @@ -210,7 +211,17 @@ public function sendTraceRegisterInfoByApi($register_email){
self::REGISTER_EMAIL => $register_email,
]);
}
}
}
// 产品加入购物车,通过api传递数据给trace系统 sku, qty, price
public function sendTraceAddToCartInfoByApi($cart_info){
if ($this->traceJsEnable && $cart_info) {
$this->apiSendTrace([
self::CART => $cart_info,
]);
}
}


// 订单生成成功,通过api传递数据给trace系统
public function sendTracePaymentPendingOrderByApi($order){
if ($this->traceJsEnable && $order) {
Expand Down

0 comments on commit 458f469

Please sign in to comment.