From ff83eb60d89d012454057b75a135f2ba03571379 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Dec 2016 21:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E9=83=A8=E5=88=86=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E5=92=8C=E8=BF=90=E8=B4=B9=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/Checkout/block/onepage/Index.php | 68 ++- .../theme/base/front/assets/css/style.css | 2 +- .../base/front/checkout/onepage/index.php | 489 ++++++++++-------- .../checkout/onepage/index/review_order.php | 42 +- 4 files changed, 343 insertions(+), 258 deletions(-) diff --git a/app/appfront/modules/Checkout/block/onepage/Index.php b/app/appfront/modules/Checkout/block/onepage/Index.php index 66c1f6e7..d06c4456 100644 --- a/app/appfront/modules/Checkout/block/onepage/Index.php +++ b/app/appfront/modules/Checkout/block/onepage/Index.php @@ -5,29 +5,61 @@ use Yii; use fec\helpers\CModule; use fec\helpers\CRequest; class Index { - protected $_payment_mothod; - - - public function getLastData(){ - - + $currency_info = Yii::$service->page->currency->getCurrencyInfo(); return [ 'payments' => $this->getPayment(), 'shippings' => $this->getShippings(), 'current_payment_mothod' => $this->_payment_mothod, + 'cart_info' => $this->getCartInfo(), + 'currency_info' => $currency_info, ]; } + + + public function getCartInfo(){ + $cart_info = Yii::$service->cart->getCartInfo(); + + if(isset($cart_info['products']) && is_array($cart_info['products'])){ + foreach($cart_info['products'] as $k=>$product_one){ + # 设置名字,得到当前store的语言名字。 + $cart_info['products'][$k]['name'] = Yii::$service->store->getStoreAttrVal($product_one['product_name'],'name'); + # 设置图片 + if(isset($product_one['product_image']['main']['image'])){ + $cart_info['products'][$k]['image'] = $product_one['product_image']['main']['image']; + } + # 产品的url + $cart_info['products'][$k]['url'] = Yii::$service->url->getUrl($product_one['product_url']); + + $custom_option = isset($product_one['custom_option']) ? $product_one['custom_option'] : ''; + $custom_option_sku = $product_one['custom_option_sku']; + # 将在产品页面选择的颜色尺码等属性显示出来。 + //$custom_option_info_arr = $this->getProductOptions($product_one,$custom_option_sku); + //$cart_info['products'][$k]['custom_option_info'] = $custom_option_info_arr; + # 设置相应的custom option 对应的图片 + $custom_option_image = isset($custom_option[$custom_option_sku]['image']) ? $custom_option[$custom_option_sku]['image'] : ''; + if($custom_option_image){ + $cart_info['products'][$k]['image'] = $custom_option_image; + } + } + } + + return $cart_info; + } + + public function getShippings(){ $country = Yii::$service->helper->country->getDefaultCountry(); $cartInfo = Yii::$service->cart->quoteItem->getCartProductInfo(); $product_weight = $cartInfo['product_weight']; - $shipping_method = Yii::$service->shipping->getDefaultShipping(); + # 传递当前的货运方式,这个需要从cart中选取, + # 如果cart中没有shipping_method,那么该值为空 + $current_shipping_method = ''; $region='*'; - $shippingArr = $this->getShippingArr($product_weight,$shipping_method,$country,$region); + $shippingArr = $this->getShippingArr($product_weight,$current_shipping_method,$country,$region); return $shippingArr ; } @@ -52,15 +84,15 @@ class Index { * @return String , 通过上面的三个参数,得到各个运费方式对应的运费。 * 最后生成html */ - public function getShippingArr($weight,$shipping_method,$country,$region='*'){ - $shippingName = ''; - $now_shipping = $shipping_method; - if($now_shipping){ - $shippingName = $now_shipping; - } - if(!$shippingName){ - $shippingName = Yii::$service->shipping->getDefaultShipping(); - } + public function getShippingArr($weight,$current_shipping_method,$country,$region='*'){ + //$shippingName = ''; + //$now_shipping = $shipping_method; + //if($now_shipping){ + // $shippingName = $now_shipping; + //} + //if(!$shippingName){ + // $shippingName = Yii::$service->shipping->getDefaultShipping(); + //} $allshipping = Yii::$service->shipping->getShippingMethod(); $sr = ''; $shipping_i = 1; @@ -74,7 +106,7 @@ class Index { //var_dump($cost); $currentCurrencyCost = $cost['currentCost']; $symbol = Yii::$service->page->currency->getCurrentSymbol(); - if($shippingName == $method){ + if($current_shipping_method == $method){ $check = ' checked="checked" '; }else{ $check = ''; diff --git a/app/appfront/theme/base/front/assets/css/style.css b/app/appfront/theme/base/front/assets/css/style.css index f1ccb814..561df6f6 100644 --- a/app/appfront/theme/base/front/assets/css/style.css +++ b/app/appfront/theme/base/front/assets/css/style.css @@ -1498,7 +1498,7 @@ button.redBtn:focus , button.redBtn:active { border-width: 0 1px; } td:nth-child(2n) { - background: #f7f7f7 none repeat scroll 0 0; + background: #fefefe none repeat scroll 0 0; } .data-table td { border: 1px solid #ddd; diff --git a/app/appfront/theme/base/front/checkout/onepage/index.php b/app/appfront/theme/base/front/checkout/onepage/index.php index 4619aea0..498ed76b 100644 --- a/app/appfront/theme/base/front/checkout/onepage/index.php +++ b/app/appfront/theme/base/front/checkout/onepage/index.php @@ -1,200 +1,185 @@
- - -
- -
-
-
+ + + + +
+
-

Checkout

-

Welcome to the checkout. Fill in the fields below to complete your purchase!

- +

Checkout

+

Welcome to the checkout. Fill in the fields below to complete your purchase!

+ -
-
-
- -
    -
  • -

    Billing address

    -
  • -
  • -
    -
      -
    • -
      - - -
      -
      - - -
      -
    • -
    • -
      - - -
      +
      +
      +
      + +
        +
      • +

        Billing address

        +
      • +
      • +
        +
          +
        • +
          + + +
          +
          + + +
          +
        • +
        • +
          + + +
          + +
          +
          +
        • +
        • +
          + + +
          +
        • +
        • +
          + + +
          + +
          +
        • +
        • +
          + + +
          +
        • +
        • +
          + + +
          +
        • +
        • +
          + + +
          +
          + +
          +
        • +
        • +
          + + +
          +
        • + + -
        + +
      +
    • +
    • + +
    • +
    -
  • -
  • -
    - - -
    -
  • -
  • -
    - - +
    + +
    + 'checkout/onepage/index/shipping.php' + ]; + $shippingParam = [ + 'shippings' => $shippings, + ]; + ?> + page->widget->render($shippingView,$shippingParam); ?> + + + + 'checkout/onepage/index/payment.php' + ]; + $paymentParam = [ + 'payments' => $payments, + 'current_payment_mothod' => $current_payment_mothod, + ]; + ?> + page->widget->render($paymentView,$paymentParam); ?> + + +
    + +
    Coupon codes (optional)
    + + + +
    - -
    -
  • -
  • -
    - - -
    -
  • -
  • -
    - - -
    -
  • -
  • -
    - - + +
    +
    -
    - -
    -
  • -
  • -
    - - -
    -
  • - - - - -
- -
  • - -
  • - -
    -
    + + +
    -
    - 'checkout/onepage/index/shipping.php' - ]; - $shippingParam = [ - 'shippings' => $shippings, - ]; - ?> - page->widget->render($shippingView,$shippingParam); ?> - - - - 'checkout/onepage/index/payment.php' - ]; - $paymentParam = [ - 'payments' => $payments, - 'current_payment_mothod' => $current_payment_mothod, - ]; - ?> - page->widget->render($paymentView,$paymentParam); ?> - +
    + 'checkout/onepage/index/review_order.php' + ]; + $reviewOrderParam = [ + 'cart_info' => $cart_info, + 'currency_info' => $currency_info, + ]; + ?> + page->widget->render($reviewOrderView,$reviewOrderParam); ?> -
    - -
    Coupon codes (optional)
    - - - -
    - +
    +
     
    -
    + + +
    + -
    - 'checkout/onepage/index/review_order.php' - ]; - $reviewOrderParam = [ - ]; - ?> - page->widget->render($reviewOrderView,$reviewOrderParam); ?> - -
    -
     
    - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/appfront/theme/base/front/checkout/onepage/index/review_order.php b/app/appfront/theme/base/front/checkout/onepage/index/review_order.php index 25472b48..89ec39a0 100644 --- a/app/appfront/theme/base/front/checkout/onepage/index/review_order.php +++ b/app/appfront/theme/base/front/checkout/onepage/index/review_order.php @@ -1,19 +1,40 @@ + + + + +

    Review your order

    - + + + - - - - + + + + + + + +
    Productname Qty Subtotal
    Classic Style Solid Color Lace-up Round Toe Flat Boots For Women1$35.00
    + + 2121 + + + + + +
    @@ -21,25 +42,25 @@
    Subtotal - $35.00 +
    Shipping - $0.00 +
    Discount - -$0.00 + -
    Grand total - $35.00 +
    @@ -47,4 +68,5 @@ \ No newline at end of file +
    + \ No newline at end of file -- GitLab