index.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. ?>
  10. <?php
  11. use fecshop\app\appfront\helper\Format;
  12. use fec\helpers\CRequest;
  13. ?>
  14. <div class="main container one-column">
  15. <div class="col-main">
  16. <?= Yii::$service->page->widget->render('breadcrumbs',$this); ?>
  17. <?= Yii::$service->page->widget->render('flashmessage'); ?>
  18. <?php if(is_array($cart_info) && !empty($cart_info)): ?>
  19. <div class="product_page">
  20. <div class="cart">
  21. <div class="page-title title-buttons">
  22. <div class="shopping-cart-img">
  23. </div>
  24. </div>
  25. <div>
  26. <?php if(is_array($cart_info['products']) && (!empty($cart_info['products']))): ?>
  27. <div class="shopping-cart-div">
  28. <div class="shopping-cart-ab">
  29. </div>
  30. <table id="shopping-cart-table" class="data-table cart-table">
  31. <colgroup>
  32. <col width="1">
  33. <col width="1">
  34. <col width="">
  35. <col width="6">
  36. <col width="76">
  37. <col width="76">
  38. <col width="91">
  39. <col width="76">
  40. <col width="106">
  41. <col width="106">
  42. <col width="26">
  43. <col width="1">
  44. </colgroup>
  45. <thead>
  46. <tr class="first last">
  47. <th rowspan="1"><input type="checkbox" name="cart_select_all" class="cart_select cart_select_all" id="cart_select_all">&nbsp;<label for="cart_select_all">All</label></th>
  48. <th rowspan="1">&nbsp;</th>
  49. <th rowspan="5"><span class="nobr"><?= Yii::$service->page->translate->__('Product Name');?></span></th>
  50. <th class="a-center" colspan="1"><span class="nobr"><?= Yii::$service->page->translate->__('Unit Price');?></span></th>
  51. <th class="a-center" colspan="1"><span class="nobr"><?= Yii::$service->page->translate->__('Weight');?></span></th>
  52. <th class="a-center" colspan="1"><span class="nobr"><?= Yii::$service->page->translate->__('Volume');?></span></th>
  53. <th rowspan="1" class="a-center"><?= Yii::$service->page->translate->__('Qty');?></th>
  54. <th class="a-center" colspan="1"><?= Yii::$service->page->translate->__('Sub Price');?></th>
  55. <th class="a-center" colspan="1"><?= Yii::$service->page->translate->__('Sub Weight');?></th>
  56. <th class="a-center" colspan="1"><?= Yii::$service->page->translate->__('Sub Volume');?></th>
  57. <th rowspan="1" class="a-right">&nbsp;</th>
  58. </tr>
  59. </thead>
  60. <tfoot>
  61. </tfoot>
  62. <tbody>
  63. <?php foreach($cart_info['products'] as $product_one): ?>
  64. <tr class="first last odd">
  65. <td>
  66. <input rel="<?= $product_one['item_id']; ?>" <?= ($product_one['active'] == Yii::$service->cart->quoteItem->activeStatus ) ? 'checked="checked"' : '' ?> type="checkbox" name="cart_select_item" class="cart_select cart_select_item">
  67. </td>
  68. <td>
  69. <a href="<?= $product_one['url'] ?>" title="<?= $product_one['name'] ?>" class="product-image">
  70. <img src="<?= Yii::$service->product->image->getResize($product_one['image'],[100,100],false) ?>" alt="<?= $product_one['name'] ?>" width="75" height="75">
  71. </a>
  72. </td>
  73. <td>
  74. <h2 class="product-name">
  75. <a href="<?= $product_one['url'] ?>"><?= $product_one['name'] ?></a>
  76. </h2>
  77. <?php if(is_array($product_one['custom_option_info'])): ?>
  78. <ul>
  79. <?php foreach($product_one['custom_option_info'] as $label => $val): ?>
  80. <li><?= Yii::$service->page->translate->__(ucwords($label)).':' ?><?= Yii::$service->page->translate->__($val) ?> </li>
  81. <?php endforeach; ?>
  82. </ul>
  83. <?php endif; ?>
  84. </td>
  85. <td class="a-right">
  86. <span class="cart-price">
  87. <span class="price"><?= $currency_info['symbol']; ?><?= Format::price($product_one['product_price']); ?></span>
  88. </span>
  89. </td>
  90. <td class="a-right">
  91. <span class="cart-price">
  92. <span class="price"><?= Format::price($product_one['product_weight']); ?>Kg</span>
  93. </span>
  94. </td>
  95. <td class="a-right">
  96. <span class="cart-price">
  97. <span class="price"><?= Format::price($product_one['product_volume']); ?>c㎡</span>
  98. </span>
  99. </td>
  100. <td class="a-center">
  101. <div style="width:60px;margin:auto">
  102. <a href="javascript:void(0)" class="cartqtydown changeitemqty" rel="<?= $product_one['item_id']; ?>" num="<?= $product_one['qty']; ?>"></a>
  103. <input name="cart[qty]" size="4" title="Qty" class="input-text qty" rel="<?= $product_one['item_id']; ?>" maxlength="12" value="<?= $product_one['qty']; ?>">
  104. <a href="javascript:void(0)" class="cartqtyup changeitemqty" rel="<?= $product_one['item_id']; ?>" num="<?= $product_one['qty']; ?>"></a>
  105. <div class="clear"></div>
  106. </div>
  107. </td>
  108. <td class="a-right">
  109. <span class="cart-price">
  110. <span class="price"><?= $currency_info['symbol']; ?><?= Format::price($product_one['product_row_price']); ?></span>
  111. </span>
  112. </td>
  113. <td class="a-right">
  114. <span class="cart-price">
  115. <span class="price"><?= Format::price($product_one['product_row_weight']); ?>Kg</span>
  116. </span>
  117. </td>
  118. <td class="a-right">
  119. <span class="cart-price">
  120. <span class="price"><?= Format::price($product_one['product_row_volume']); ?>c㎡</span>
  121. </span>
  122. </td>
  123. <td class="a-right last">
  124. <a style="margin-right: 15px;float: right;" href="javascript:void(0)" rel="<?= $product_one['item_id']; ?>" title="Remove item" class="btn-remove btn-remove2"><?= Yii::$service->page->translate->__('Remove item');?></a>
  125. </td>
  126. </tr>
  127. <?php endforeach; ?>
  128. </tbody>
  129. </table>
  130. </div>
  131. <?php endif; ?>
  132. </div>
  133. <div class="cart-collaterals">
  134. <div class="col2-set">
  135. <div class="col-1">
  136. </div>
  137. <div class="col-2">
  138. <form id="discount-coupon-form" >
  139. <div class="discount">
  140. <h2><?= Yii::$service->page->translate->__('Discount Codes');?></h2>
  141. <div class="discount-form">
  142. <label for="coupon_code"><?= Yii::$service->page->translate->__('Enter your coupon code if you have one.');?></label>
  143. <div class="input-box">
  144. <input type="hidden" class="couponType" value="<?= $cart_info['coupon_code'] ? 1 : 2 ; ?>" />
  145. <input style="color:#777;" class="input-text" id="coupon_code" name="coupon_code" value="<?= $cart_info['coupon_code']; ?>">
  146. </div>
  147. <div class="buttons-cou">
  148. <a href="javascript:void(0)" class="add_coupon_submit submitbutton"><span><span><?= Yii::$service->page->translate->__($cart_info['coupon_code'] ? 'Cancel Coupon' : 'Add Coupon') ; ?></span></span> </a>
  149. </div>
  150. <div class="clear"></div>
  151. <div class="coupon_add_log"></div>
  152. </div>
  153. </div>
  154. </form>
  155. </div>
  156. </div>
  157. <div class="totals cart-totals">
  158. <div class="process_total">
  159. <table id="shopping-cart-totals-table">
  160. <colgroup>
  161. <col>
  162. <col width="1">
  163. </colgroup>
  164. <tbody>
  165. <tr>
  166. <td style="" class="a-left" colspan="1">
  167. <?= Yii::$service->page->translate->__('Sub Totla');?> :
  168. </td>
  169. <td style="" class="a-right">
  170. <span class="price">
  171. <?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_total']); ?>
  172. </span>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td style="" class="a-left" colspan="1">
  177. <?= Yii::$service->page->translate->__('Sub Weight');?> :
  178. </td>
  179. <td style="" class="a-right">
  180. <span class="price">
  181. <?= Format::price($cart_info['product_weight']); ?> Kg
  182. </span>
  183. </td>
  184. </tr>
  185. <tr>
  186. <td style="" class="a-left" colspan="1">
  187. <?= Yii::$service->page->translate->__('Sub Volume');?> :
  188. </td>
  189. <td style="" class="a-right">
  190. <span class="price">
  191. <?= Format::price($cart_info['product_volume']); ?> c㎡
  192. </span>
  193. </td>
  194. </tr>
  195. <tr>
  196. <td style="" class="a-left" colspan="1">
  197. <?= Yii::$service->page->translate->__('Discount');?> : </td>
  198. <td style="" class="a-right">
  199. <span class="price">-<?= $currency_info['symbol']; ?><?= Format::price($cart_info['coupon_cost']); ?></span> </td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <table id="shopping-cart-totals-table2">
  204. <colgroup>
  205. <col>
  206. <col width="90">
  207. </colgroup>
  208. <tbody>
  209. <tr>
  210. <td style="" class="a-left" colspan="1">
  211. <strong><?= Yii::$service->page->translate->__('Grand Total');?></strong>
  212. </td>
  213. <td style="" class="a-right">
  214. <strong><span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['grand_total']) ?></span></strong>
  215. </td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </div>
  220. <div class="proceed_to_checkout">
  221. <button onclick="location.href='<?= Yii::$service->url->getUrl('checkout/onepage'); ?>'" type="button" title="Proceed to Checkout" class="button btn-proceed-checkout btn-checkout"><span><span><?= Yii::$service->page->translate->__('Proceed to Pay');?></span></span></button>
  222. <span class="or">- <?= Yii::$service->page->translate->__('OR');?> - </span>
  223. <a class="express_paypal" href="<?= Yii::$service->url->getUrl('payment/paypal/express/start'); ?>">
  224. </a>
  225. </div>
  226. </div>
  227. <div class="clear"></div>
  228. </div>
  229. </div>
  230. </div>
  231. <?php else: ?>
  232. <div class="empty_cart">
  233. <?php
  234. $param = ['urlB' => '<a rel="nofollow" href="'.Yii::$service->url->getUrl('customer/account/login').'">','urlE' =>'</a>'];
  235. ?>
  236. <div id="empty_cart_info">
  237. <?= Yii::$service->page->translate->__('Your Shopping Cart is empty');?>
  238. <a href="<?= Yii::$service->url->homeUrl(); ?>"><?= Yii::$service->page->translate->__('Start shopping now!');?></a>
  239. <br>
  240. <?= Yii::$service->page->translate->__('Please {urlB}log in{urlE} to view the products you have previously added to your Shopping Cart.',$param);?>
  241. </div>
  242. </div>
  243. <?php endif; ?>
  244. </div>
  245. </div>
  246. <script>
  247. // add to cart js
  248. <?php $this->beginBlock('changeCartInfo') ?>
  249. csrfName = "<?= CRequest::getCsrfName() ?>";
  250. csrfVal = "<?= CRequest::getCsrfValue() ?>";
  251. $(document).ready(function(){
  252. // set select all checkbox
  253. selectall = "<?= Yii::$app->request->get('selectall') ?>";
  254. selectAllChecked = false;
  255. if (selectall == 1) {
  256. selectAllChecked = true;
  257. } else {
  258. item_select_all = 1;
  259. $(".cart_select_item").each(function(){
  260. checked = $(this).is(':checked');
  261. if (checked == false) {
  262. item_select_all = 0;
  263. }
  264. });
  265. if (item_select_all == 1) {
  266. selectAllChecked = true;
  267. }
  268. }
  269. $(".cart_select_all").attr("checked",selectAllChecked);
  270. currentUrl = "<?= Yii::$service->url->getUrl('checkout/cart') ?>";
  271. updateCartInfoUrl = "<?= Yii::$service->url->getUrl('checkout/cart/updateinfo') ?>";
  272. selectOneProductUrl = "<?= Yii::$service->url->getUrl('checkout/cart/selectone') ?>";
  273. selectAllProductUrl = "<?= Yii::$service->url->getUrl('checkout/cart/selectall') ?>";
  274. $(".cartqtydown").click(function(){
  275. $item_id = $(this).attr("rel");
  276. num = $(this).attr("num");
  277. if(num > 1){
  278. $data = {
  279. item_id:$item_id,
  280. up_type:"less_one"
  281. };
  282. $data[csrfName] = csrfVal;
  283. jQuery.ajax({
  284. async:true,
  285. timeout: 6000,
  286. dataType: 'json',
  287. type:'post',
  288. data: $data,
  289. url:updateCartInfoUrl,
  290. success:function(data, textStatus){
  291. if(data.status == 'success'){
  292. window.location.href=currentUrl;
  293. }
  294. },
  295. error:function (XMLHttpRequest, textStatus, errorThrown){}
  296. });
  297. }
  298. });
  299. $(".cartqtyup").click(function(){
  300. $item_id = $(this).attr("rel");
  301. $data = {
  302. item_id:$item_id,
  303. up_type:"add_one"
  304. };
  305. $data[csrfName] = csrfVal;
  306. $.ajax({
  307. async:true,
  308. timeout: 6000,
  309. dataType: 'json',
  310. type:'post',
  311. data: $data,
  312. url:updateCartInfoUrl,
  313. success:function(data, textStatus){
  314. if(data.status == 'success'){
  315. window.location.href=currentUrl;
  316. }
  317. },
  318. error:function (XMLHttpRequest, textStatus, errorThrown){}
  319. });
  320. });
  321. $(".btn-remove").click(function(){
  322. $item_id = $(this).attr("rel");
  323. $data = {
  324. item_id:$item_id,
  325. up_type:"remove"
  326. };
  327. $data[csrfName] = csrfVal;
  328. $.ajax({
  329. async:true,
  330. timeout: 6000,
  331. dataType: 'json',
  332. type:'post',
  333. data: $data,
  334. url:updateCartInfoUrl,
  335. success:function(data, textStatus){
  336. if(data.status == 'success'){
  337. window.location.href=currentUrl;
  338. }
  339. },
  340. error:function (XMLHttpRequest, textStatus, errorThrown){}
  341. });
  342. });
  343. $(".cart_select_item").click(function(){
  344. $item_id = $(this).attr("rel");
  345. checked = $(this).is(':checked');
  346. checked = checked ? 1 : 0;
  347. $data = {
  348. item_id:$item_id,
  349. checked:checked
  350. };
  351. $data[csrfName] = csrfVal;
  352. $.ajax({
  353. async:true,
  354. timeout: 6000,
  355. dataType: 'json',
  356. type:'post',
  357. data: $data,
  358. url:selectOneProductUrl,
  359. success:function(data, textStatus){
  360. if(data.status == 'success'){
  361. window.location.href = currentUrl;
  362. }
  363. },
  364. error:function (XMLHttpRequest, textStatus, errorThrown){}
  365. });
  366. });
  367. $(".cart_select_all").click(function(){
  368. checked = $(this).is(':checked');
  369. checked = checked ? 1 : 0;
  370. $data = {
  371. checked:checked
  372. };
  373. $data[csrfName] = csrfVal;
  374. selectCurrentUrl = currentUrl + '?selectall=' + checked;
  375. $.ajax({
  376. async:true,
  377. timeout: 6000,
  378. dataType: 'json',
  379. type:'post',
  380. data: $data,
  381. url:selectAllProductUrl,
  382. success:function(data, textStatus){
  383. if(data.status == 'success'){
  384. window.location.href = selectCurrentUrl;
  385. }
  386. },
  387. error:function (XMLHttpRequest, textStatus, errorThrown){}
  388. });
  389. });
  390. $(".add_coupon_submit").click(function(){
  391. coupon_code = $("#coupon_code").val();
  392. coupon_type = $(".couponType").val();
  393. coupon_url = "";
  394. if(coupon_type == 2){
  395. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/addcoupon'); ?>";
  396. }else if(coupon_type == 1){
  397. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/cancelcoupon'); ?>";
  398. }
  399. if(!coupon_code){
  400. //alert("coupon can not empty!");
  401. }
  402. $data = {"coupon_code":coupon_code};
  403. $data[csrfName] = csrfVal;
  404. //coupon_url = $("#discount-coupon-form").attr("action");
  405. $.ajax({
  406. async:true,
  407. timeout: 6000,
  408. dataType: 'json',
  409. type: 'post',
  410. data: $data,
  411. url:coupon_url,
  412. success:function(data, textStatus){
  413. if(data.status == 'success'){
  414. window.location.href=currentUrl;
  415. }else if(data.content == 'nologin'){
  416. window.location.href="<?= Yii::$service->url->getUrl('customer/account/login'); ?>";
  417. }else{
  418. $(".coupon_add_log").html(data.content);
  419. }
  420. },
  421. error:function (XMLHttpRequest, textStatus, errorThrown){}
  422. });
  423. });
  424. });
  425. <?php $this->endBlock(); ?>
  426. <?php $this->registerJs($this->blocks['changeCartInfo'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
  427. </script>
  428. <?php // Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) // 这个改成服务端发送加入购物车数据,而不是js传递的方式 ?>