Skip to content

Commit

Permalink
cart代码结构优化
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Apr 3, 2020
1 parent 998bf7e commit d2c259e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions services/cart/QuoteItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,14 @@ public function getActiveItemQty()

return $item_qty;
}

/**
* 得到购物车产品的排序数组
*/
public function getCartProductOrderBy()
{

return ['active' => SORT_ASC, 'updated_at' => SORT_DESC];
}
/**
* @param $activeProduct | boolean , 是否只要active的产品
* @return array , foramt:
Expand All @@ -270,7 +277,7 @@ public function getCartProductInfo($activeProduct = true)
if (!isset($this->_cart_product_info[$cart_id])) {
$data = $this->_itemModel->find()->where([
'cart_id' => $cart_id,
])->orderBy( ['active' => SORT_ASC, 'updated_at' => SORT_DESC]) // 加入按照active updated_at 进行排序
])->orderBy( $this->getCartProductOrderBy()) // 加入按照active updated_at 进行排序
->all();
if (is_array($data) && !empty($data)) {
foreach ($data as $one) {
Expand Down

0 comments on commit d2c259e

Please sign in to comment.