/** * 清空购物车商品 * * @param string $storeId * @return integer the number of rows deleted */ public function clearCartGoods($storeId = null) { $condition = ['user_id' => $this->id]; if ($storeId !== null) { $condition['store_id'] = $storeId; } return CartGoods::deleteAll($condition); }