index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. <?php if($product_one['customsize']): ?>
  85. <ul>
  86. <?php
  87. $customsize = stripslashes($product_one['customsize']);
  88. $customsize = json_decode($customsize,true);
  89. ?>
  90. <?php foreach($customsize as $k => $v): ?>
  91. <li><?=$k?>:<?=$v?> </li>
  92. <?php endforeach; ?>
  93. </ul>
  94. <?php endif; ?>
  95. </td>
  96. <td class="a-right">
  97. <span class="cart-price">
  98. <span class="price"><?= $currency_info['symbol']; ?><?= Format::price($product_one['product_price']); ?></span>
  99. </span>
  100. </td>
  101. <td class="a-right">
  102. <span class="cart-price">
  103. <span class="price"><?= Format::price($product_one['product_weight']); ?>Kg</span>
  104. </span>
  105. </td>
  106. <td class="a-right">
  107. <span class="cart-price">
  108. <span class="price"><?= Format::price($product_one['product_volume']); ?>c㎡</span>
  109. </span>
  110. </td>
  111. <td class="a-center">
  112. <div style="width:60px;margin:auto">
  113. <a href="javascript:void(0)" class="cartqtydown changeitemqty" rel="<?= $product_one['item_id']; ?>" num="<?= $product_one['qty']; ?>"></a>
  114. <input name="cart[qty]" size="4" title="Qty" class="input-text qty" rel="<?= $product_one['item_id']; ?>" maxlength="12" value="<?= $product_one['qty']; ?>">
  115. <a href="javascript:void(0)" class="cartqtyup changeitemqty" rel="<?= $product_one['item_id']; ?>" num="<?= $product_one['qty']; ?>"></a>
  116. <div class="clear"></div>
  117. </div>
  118. </td>
  119. <td class="a-right">
  120. <span class="cart-price">
  121. <span class="price"><?= $currency_info['symbol']; ?><?= Format::price($product_one['product_row_price']); ?></span>
  122. </span>
  123. </td>
  124. <td class="a-right">
  125. <span class="cart-price">
  126. <span class="price"><?= Format::price($product_one['product_row_weight']); ?>Kg</span>
  127. </span>
  128. </td>
  129. <td class="a-right">
  130. <span class="cart-price">
  131. <span class="price"><?= Format::price($product_one['product_row_volume']); ?>c㎡</span>
  132. </span>
  133. </td>
  134. <td class="a-right last">
  135. <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>
  136. </td>
  137. </tr>
  138. <?php endforeach; ?>
  139. </tbody>
  140. </table>
  141. </div>
  142. <?php endif; ?>
  143. </div>
  144. <div class="cart-collaterals">
  145. <div class="col2-set">
  146. <div class="col-1">
  147. </div>
  148. <div class="col-2">
  149. <form id="discount-coupon-form" >
  150. <div class="discount">
  151. <h2><?= Yii::$service->page->translate->__('Discount Codes');?></h2>
  152. <div class="discount-form">
  153. <label for="coupon_code"><?= Yii::$service->page->translate->__('Enter your coupon code if you have one.');?></label>
  154. <div class="input-box">
  155. <input type="hidden" class="couponType" value="<?= $cart_info['coupon_code'] ? 1 : 2 ; ?>" />
  156. <input style="color:#777;" class="input-text" id="coupon_code" name="coupon_code" value="<?= $cart_info['coupon_code']; ?>">
  157. </div>
  158. <div class="buttons-cou">
  159. <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>
  160. </div>
  161. <div class="clear"></div>
  162. <div class="coupon_add_log"></div>
  163. </div>
  164. </div>
  165. </form>
  166. </div>
  167. </div>
  168. <div class="totals cart-totals">
  169. <div class="process_total">
  170. <table id="shopping-cart-totals-table">
  171. <colgroup>
  172. <col>
  173. <col width="1">
  174. </colgroup>
  175. <tbody>
  176. <tr>
  177. <td style="" class="a-left" colspan="1">
  178. <?= Yii::$service->page->translate->__('Sub Totla');?> :
  179. </td>
  180. <td style="" class="a-right">
  181. <span class="price">
  182. <?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_total']); ?>
  183. </span>
  184. </td>
  185. </tr>
  186. <tr>
  187. <td style="" class="a-left" colspan="1">
  188. <?= Yii::$service->page->translate->__('Sub Weight');?> :
  189. </td>
  190. <td style="" class="a-right">
  191. <span class="price">
  192. <?= Format::price($cart_info['product_weight']); ?> Kg
  193. </span>
  194. </td>
  195. </tr>
  196. <tr>
  197. <td style="" class="a-left" colspan="1">
  198. <?= Yii::$service->page->translate->__('Sub Volume');?> :
  199. </td>
  200. <td style="" class="a-right">
  201. <span class="price">
  202. <?= Format::price($cart_info['product_volume']); ?> c㎡
  203. </span>
  204. </td>
  205. </tr>
  206. <tr>
  207. <td style="" class="a-left" colspan="1">
  208. <?= Yii::$service->page->translate->__('Discount');?> : </td>
  209. <td style="" class="a-right">
  210. <span class="price">-<?= $currency_info['symbol']; ?><?= Format::price($cart_info['coupon_cost']); ?></span> </td>
  211. </tr>
  212. </tbody>
  213. </table>
  214. <table id="shopping-cart-totals-table2">
  215. <colgroup>
  216. <col>
  217. <col width="90">
  218. </colgroup>
  219. <tbody>
  220. <tr>
  221. <td style="" class="a-left" colspan="1">
  222. <strong><?= Yii::$service->page->translate->__('Grand Total');?></strong>
  223. </td>
  224. <td style="" class="a-right">
  225. <strong><span class="price"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['grand_total']) ?></span></strong>
  226. </td>
  227. </tr>
  228. </tbody>
  229. </table>
  230. </div>
  231. <div class="proceed_to_checkout">
  232. <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>
  233. <span class="or">- <?= Yii::$service->page->translate->__('OR');?> - </span>
  234. <a class="express_paypal" href="<?= Yii::$service->url->getUrl('payment/paypal/express/start'); ?>">
  235. </a>
  236. </div>
  237. </div>
  238. <div class="clear"></div>
  239. </div>
  240. </div>
  241. </div>
  242. <?php else: ?>
  243. <div class="empty_cart">
  244. <?php
  245. $param = ['urlB' => '<a rel="nofollow" href="'.Yii::$service->url->getUrl('customer/account/login').'">','urlE' =>'</a>'];
  246. ?>
  247. <div id="empty_cart_info">
  248. <?= Yii::$service->page->translate->__('Your Shopping Cart is empty');?>
  249. <a href="<?= Yii::$service->url->homeUrl(); ?>"><?= Yii::$service->page->translate->__('Start shopping now!');?></a>
  250. <br>
  251. <?= Yii::$service->page->translate->__('Please {urlB}log in{urlE} to view the products you have previously added to your Shopping Cart.',$param);?>
  252. </div>
  253. </div>
  254. <?php endif; ?>
  255. </div>
  256. </div>
  257. <script>
  258. // add to cart js
  259. <?php $this->beginBlock('changeCartInfo') ?>
  260. csrfName = "<?= CRequest::getCsrfName() ?>";
  261. csrfVal = "<?= CRequest::getCsrfValue() ?>";
  262. $(document).ready(function(){
  263. // set select all checkbox
  264. selectall = "<?= Yii::$app->request->get('selectall') ?>";
  265. selectAllChecked = false;
  266. if (selectall == 1) {
  267. selectAllChecked = true;
  268. } else {
  269. item_select_all = 1;
  270. $(".cart_select_item").each(function(){
  271. checked = $(this).is(':checked');
  272. if (checked == false) {
  273. item_select_all = 0;
  274. }
  275. });
  276. if (item_select_all == 1) {
  277. selectAllChecked = true;
  278. }
  279. }
  280. $(".cart_select_all").attr("checked",selectAllChecked);
  281. currentUrl = "<?= Yii::$service->url->getUrl('checkout/cart') ?>";
  282. updateCartInfoUrl = "<?= Yii::$service->url->getUrl('checkout/cart/updateinfo') ?>";
  283. selectOneProductUrl = "<?= Yii::$service->url->getUrl('checkout/cart/selectone') ?>";
  284. selectAllProductUrl = "<?= Yii::$service->url->getUrl('checkout/cart/selectall') ?>";
  285. $(".cartqtydown").click(function(){
  286. $item_id = $(this).attr("rel");
  287. num = $(this).attr("num");
  288. if(num > 1){
  289. $data = {
  290. item_id:$item_id,
  291. up_type:"less_one"
  292. };
  293. $data[csrfName] = csrfVal;
  294. jQuery.ajax({
  295. async:true,
  296. timeout: 6000,
  297. dataType: 'json',
  298. type:'post',
  299. data: $data,
  300. url:updateCartInfoUrl,
  301. success:function(data, textStatus){
  302. if(data.status == 'success'){
  303. window.location.href=currentUrl;
  304. }
  305. },
  306. error:function (XMLHttpRequest, textStatus, errorThrown){}
  307. });
  308. }
  309. });
  310. $(".cartqtyup").click(function(){
  311. $item_id = $(this).attr("rel");
  312. $data = {
  313. item_id:$item_id,
  314. up_type:"add_one"
  315. };
  316. $data[csrfName] = csrfVal;
  317. $.ajax({
  318. async:true,
  319. timeout: 6000,
  320. dataType: 'json',
  321. type:'post',
  322. data: $data,
  323. url:updateCartInfoUrl,
  324. success:function(data, textStatus){
  325. if(data.status == 'success'){
  326. window.location.href=currentUrl;
  327. }
  328. },
  329. error:function (XMLHttpRequest, textStatus, errorThrown){}
  330. });
  331. });
  332. $(".btn-remove").click(function(){
  333. $item_id = $(this).attr("rel");
  334. $data = {
  335. item_id:$item_id,
  336. up_type:"remove"
  337. };
  338. $data[csrfName] = csrfVal;
  339. $.ajax({
  340. async:true,
  341. timeout: 6000,
  342. dataType: 'json',
  343. type:'post',
  344. data: $data,
  345. url:updateCartInfoUrl,
  346. success:function(data, textStatus){
  347. if(data.status == 'success'){
  348. window.location.href=currentUrl;
  349. }
  350. },
  351. error:function (XMLHttpRequest, textStatus, errorThrown){}
  352. });
  353. });
  354. $(".cart_select_item").click(function(){
  355. $item_id = $(this).attr("rel");
  356. checked = $(this).is(':checked');
  357. checked = checked ? 1 : 0;
  358. $data = {
  359. item_id:$item_id,
  360. checked:checked
  361. };
  362. $data[csrfName] = csrfVal;
  363. $.ajax({
  364. async:true,
  365. timeout: 6000,
  366. dataType: 'json',
  367. type:'post',
  368. data: $data,
  369. url:selectOneProductUrl,
  370. success:function(data, textStatus){
  371. if(data.status == 'success'){
  372. window.location.href = currentUrl;
  373. }
  374. },
  375. error:function (XMLHttpRequest, textStatus, errorThrown){}
  376. });
  377. });
  378. $(".cart_select_all").click(function(){
  379. checked = $(this).is(':checked');
  380. checked = checked ? 1 : 0;
  381. $data = {
  382. checked:checked
  383. };
  384. $data[csrfName] = csrfVal;
  385. selectCurrentUrl = currentUrl + '?selectall=' + checked;
  386. $.ajax({
  387. async:true,
  388. timeout: 6000,
  389. dataType: 'json',
  390. type:'post',
  391. data: $data,
  392. url:selectAllProductUrl,
  393. success:function(data, textStatus){
  394. if(data.status == 'success'){
  395. window.location.href = selectCurrentUrl;
  396. }
  397. },
  398. error:function (XMLHttpRequest, textStatus, errorThrown){}
  399. });
  400. });
  401. $(".add_coupon_submit").click(function(){
  402. coupon_code = $("#coupon_code").val();
  403. coupon_type = $(".couponType").val();
  404. coupon_url = "";
  405. if(coupon_type == 2){
  406. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/addcoupon'); ?>";
  407. }else if(coupon_type == 1){
  408. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/cancelcoupon'); ?>";
  409. }
  410. if(!coupon_code){
  411. //alert("coupon can not empty!");
  412. }
  413. $data = {"coupon_code":coupon_code};
  414. $data[csrfName] = csrfVal;
  415. //coupon_url = $("#discount-coupon-form").attr("action");
  416. $.ajax({
  417. async:true,
  418. timeout: 6000,
  419. dataType: 'json',
  420. type: 'post',
  421. data: $data,
  422. url:coupon_url,
  423. success:function(data, textStatus){
  424. if(data.status == 'success'){
  425. window.location.href=currentUrl;
  426. }else if(data.content == 'nologin'){
  427. window.location.href="<?= Yii::$service->url->getUrl('customer/account/login'); ?>";
  428. }else{
  429. $(".coupon_add_log").html(data.content);
  430. }
  431. },
  432. error:function (XMLHttpRequest, textStatus, errorThrown){}
  433. });
  434. });
  435. });
  436. <?php $this->endBlock(); ?>
  437. <?php $this->registerJs($this->blocks['changeCartInfo'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
  438. </script>
  439. <?php // Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) // 这个改成服务端发送加入购物车数据,而不是js传递的方式 ?>