index.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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\apphtml5\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('flashmessage'); ?>
  17. <?php if(is_array($cart_info) && !empty($cart_info)): ?>
  18. <div class="product_page">
  19. <div class="cart">
  20. <div class="page-title title-buttons">
  21. <div class="shopping-cart-img">
  22. <?= Yii::$service->page->translate->__('Shopping Cart'); ?>
  23. </div>
  24. </div>
  25. <div class="cart_info">
  26. <div class="cart_select_div">
  27. <input id="cart_select_all" type="checkbox" name="cart_select_all" class="cart_select cart_select_all">
  28. &nbsp;
  29. <label for="cart_select_all">Select All Product</label>
  30. </div>
  31. <?php if(is_array($cart_info['products']) && (!empty($cart_info['products']))): ?>
  32. <?php foreach($cart_info['products'] as $product_one): ?>
  33. <div class="row">
  34. <div class="col-33">
  35. <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">
  36. <a external href="<?= $product_one['url'] ?>" title="<?= $product_one['name'] ?>" class="product-image">
  37. <img src="<?= Yii::$service->product->image->getResize($product_one['image'],[150,150],false) ?>" alt="<?= $product_one['name'] ?>" width="75" height="75">
  38. </a>
  39. </div>
  40. <div class="col-66">
  41. <h2 class="product-name">
  42. <a external href="<?= $product_one['url'] ?>"><?= $product_one['name'] ?></a>
  43. </h2>
  44. <?php if(is_array($product_one['custom_option_info'])): ?>
  45. <ul class="options">
  46. <?php foreach($product_one['custom_option_info'] as $label => $val): ?>
  47. <li><?= Yii::$service->page->translate->__(ucwords($label).':') ?><?= Yii::$service->page->translate->__($val) ?> </li>
  48. <?php endforeach; ?>
  49. </ul>
  50. <div class="clear"></div>
  51. <?php endif; ?>
  52. <?php if($product_one['customsize']): ?>
  53. <ul>
  54. <?php
  55. $customsize = stripslashes($product_one['customsize']);
  56. $customsize = json_decode($customsize,true);
  57. ?>
  58. <?php foreach($customsize as $k => $v): ?>
  59. <li><?=$k?>:<?=$v?> </li>
  60. <?php endforeach; ?>
  61. </ul>
  62. <?php endif; ?>
  63. <div class="clear"></div>
  64. <span class="cart-price">
  65. <span class="price"><?= $currency_info['symbol']; ?><?= Format::price($product_one['product_price']); ?></span>
  66. </span>
  67. <div class="cart_qty">
  68. <a externalhref="javascript:void(0)" class="cartqtydown changeitemqty" rel="<?= $product_one['item_id']; ?>" num="<?= $product_one['qty']; ?>">-</a>
  69. <input name="cart[qty]" size="4" title="Qty" class="input-text qty" rel="<?= $product_one['item_id']; ?>" maxlength="12" value="<?= $product_one['qty']; ?>">
  70. <a externalhref="javascript:void(0)" class="cartqtyup changeitemqty" rel="<?= $product_one['item_id']; ?>" num="<?= $product_one['qty']; ?>">+</a>
  71. <div class="clear"></div>
  72. </div>
  73. <a externalhref="javascript:void(0)" rel="<?= $product_one['item_id']; ?>" title="Remove item" class="btn-remove btn-remove2"><span class="icon icon-remove"></span></a>
  74. </div>
  75. </div>
  76. <?php endforeach; ?>
  77. <?php endif; ?>
  78. </div>
  79. <div class="cart-collaterals">
  80. <div class="col2-set">
  81. <div class="col-1">
  82. </div>
  83. <div class="col-2">
  84. <form id="discount-coupon-form" >
  85. <div class="discount">
  86. <h2><?= Yii::$service->page->translate->__('Discount Codes');?></h2>
  87. <div class="discount-form">
  88. <div class="input-box">
  89. <div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset">
  90. <input type="hidden" class="couponType" value="<?= $cart_info['coupon_code'] ? 1 : 2 ; ?>" />
  91. <input style="color:#777;" class="input-text" id="coupon_code" name="coupon_code" value="<?= $cart_info['coupon_code']; ?>">
  92. </div>
  93. </div>
  94. <div class="buttons-coupon">
  95. <a external data-role="button" href="javascript:void(0)" class="add_coupon_submit submitbutton ui-link ui-btn ui-shadow ui-corner-all" role="button">
  96. <span>
  97. <span><?= Yii::$service->page->translate->__($cart_info['coupon_code'] ? 'Cancel Coupon' : 'Add Coupon') ; ?></span>
  98. </span>
  99. </a>
  100. </div>
  101. <div class="clear"></div>
  102. <div class="coupon_add_log"></div>
  103. </div>
  104. </div>
  105. </form>
  106. <div class="clear"></div>
  107. </div>
  108. </div>
  109. <div class="cart_cost">
  110. <div class="row no-gutter">
  111. <div class="col-66"><?= Yii::$service->page->translate->__('Sub Total');?> : </div>
  112. <div class="col-33"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_total']); ?></div>
  113. </div>
  114. <div class="row no-gutter">
  115. <div class="col-66"><?= Yii::$service->page->translate->__('Sub Weight');?> : </div>
  116. <div class="col-33"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_weight']); ?> Kg</div>
  117. </div>
  118. <div class="row no-gutter">
  119. <div class="col-66"><?= Yii::$service->page->translate->__('Sub Volume');?> : </div>
  120. <div class="col-33"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['product_volume']); ?> c㎡</div>
  121. </div>
  122. <div class="row no-gutter">
  123. <div class="col-66"><?= Yii::$service->page->translate->__('Shipping Cost');?> : </div>
  124. <div class="col-33"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['shipping_cost']); ?></div>
  125. </div>
  126. <div class="row no-gutter">
  127. <div class="col-66"><?= Yii::$service->page->translate->__('Discount');?> :</div>
  128. <div class="col-33">-<?= $currency_info['symbol']; ?><?= Format::price($cart_info['coupon_cost']); ?>%</div>
  129. </div>
  130. <div class="row no-gutter">
  131. <div class="col-66"><?= Yii::$service->page->translate->__('Grand Total');?> :</div>
  132. <div class="col-33"><?= $currency_info['symbol']; ?><?= Format::price($cart_info['grand_total']) ?></div>
  133. </div>
  134. </div>
  135. <div class="totals cart-totals">
  136. <div class="proceed_to_checkout">
  137. <div class="row no-gutter">
  138. <div class="col-50">
  139. <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>
  140. </div>
  141. <div class="col-50">
  142. <a external class="express_paypal" href="<?= Yii::$service->url->getUrl('payment/paypal/express/start'); ?>">
  143. <img src="<?= Yii::$service->image->getImgUrl('/images/pay.png') ?>" />
  144. </a>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="clear"></div>
  150. </div>
  151. </div>
  152. </div>
  153. <?php else: ?>
  154. <div class="empty_cart ">
  155. <?php
  156. $param = ['urlB' => '<a external rel="nofollow" href="'.Yii::$service->url->getUrl('customer/account/login').'">','urlE' =>'</a>'];
  157. ?>
  158. <div id="empty_cart_info">
  159. <?= Yii::$service->page->translate->__('Your Shopping Cart is empty');?>
  160. <a external href="<?= Yii::$service->url->homeUrl(); ?>"><?= Yii::$service->page->translate->__('Start shopping now!');?></a>
  161. <br>
  162. <?= Yii::$service->page->translate->__('Please {urlB}log in{urlE} to view the products you have previously added to your Shopping Cart.',$param);?>
  163. </div>
  164. </div>
  165. <div class="empty_cart_img">
  166. </div>
  167. <?php endif; ?>
  168. </div>
  169. </div>
  170. <script>
  171. // add to cart js
  172. <?php $this->beginBlock('changeCartInfo') ?>
  173. csrfName = "<?= CRequest::getCsrfName() ?>";
  174. csrfVal = "<?= CRequest::getCsrfValue() ?>";
  175. $(document).ready(function(){
  176. // set select all checkbox
  177. selectall = "<?= Yii::$app->request->get('selectall') ?>";
  178. selectAllChecked = false;
  179. if (selectall == 1) {
  180. selectAllChecked = true;
  181. } else {
  182. item_select_all = 1;
  183. $(".cart_select_item").each(function(){
  184. checked = $(this).is(':checked');
  185. if (checked == false) {
  186. item_select_all = 0;
  187. }
  188. });
  189. if (item_select_all == 1) {
  190. selectAllChecked = true;
  191. }
  192. }
  193. if (selectAllChecked) {
  194. $(".cart_select_all").attr("checked",selectAllChecked);
  195. } else {
  196. $(".cart_select_all").removeAttr("checked");
  197. }
  198. currentUrl = "<?= Yii::$service->url->getUrl('checkout/cart') ?>";
  199. updateCartInfoUrl = "<?= Yii::$service->url->getUrl('checkout/cart/updateinfo') ?>";
  200. selectOneProductUrl = "<?= Yii::$service->url->getUrl('checkout/cart/selectone') ?>";
  201. selectAllProductUrl = "<?= Yii::$service->url->getUrl('checkout/cart/selectall') ?>";
  202. $(".cartqtydown").click(function(){
  203. $item_id = $(this).attr("rel");
  204. num = $(this).attr("num");
  205. if(num > 1){
  206. $data = {
  207. item_id:$item_id,
  208. up_type:"less_one"
  209. };
  210. $data[csrfName] = csrfVal;
  211. $.ajax({
  212. async:true,
  213. timeout: 6000,
  214. dataType: 'json',
  215. type:'post',
  216. data: $data,
  217. url:updateCartInfoUrl,
  218. success:function(data, textStatus){
  219. if(data.status == 'success'){
  220. window.location.href=currentUrl;
  221. }
  222. },
  223. error:function (XMLHttpRequest, textStatus, errorThrown){}
  224. });
  225. }
  226. });
  227. $(".cartqtyup").click(function(){
  228. $item_id = $(this).attr("rel");
  229. $data = {
  230. item_id:$item_id,
  231. up_type:"add_one"
  232. };
  233. $data[csrfName] = csrfVal;
  234. $.ajax({
  235. async:true,
  236. timeout: 6000,
  237. dataType: 'json',
  238. type:'post',
  239. data: $data,
  240. url:updateCartInfoUrl,
  241. success:function(data, textStatus){
  242. if(data.status == 'success'){
  243. window.location.href=currentUrl;
  244. }
  245. },
  246. error:function (XMLHttpRequest, textStatus, errorThrown){}
  247. });
  248. });
  249. $(".btn-remove").click(function(){
  250. $item_id = $(this).attr("rel");
  251. $data = {
  252. item_id:$item_id,
  253. up_type:"remove"
  254. };
  255. $data[csrfName] = csrfVal;
  256. $.ajax({
  257. async:true,
  258. timeout: 6000,
  259. dataType: 'json',
  260. type:'post',
  261. data: $data,
  262. url:updateCartInfoUrl,
  263. success:function(data, textStatus){
  264. if(data.status == 'success'){
  265. window.location.href=currentUrl;
  266. }
  267. },
  268. error:function (XMLHttpRequest, textStatus, errorThrown){}
  269. });
  270. });
  271. $(".cart_select_item").click(function(){
  272. $item_id = $(this).attr("rel");
  273. checked = $(this).is(':checked');
  274. checked = checked ? 1 : 0;
  275. $data = {
  276. item_id:$item_id,
  277. checked:checked
  278. };
  279. $data[csrfName] = csrfVal;
  280. $.ajax({
  281. async:true,
  282. timeout: 6000,
  283. dataType: 'json',
  284. type:'post',
  285. data: $data,
  286. url:selectOneProductUrl,
  287. success:function(data, textStatus){
  288. if(data.status == 'success'){
  289. window.location.href = currentUrl;
  290. }
  291. },
  292. error:function (XMLHttpRequest, textStatus, errorThrown){}
  293. });
  294. });
  295. $(".cart_select_all").click(function(){
  296. checked = $(this).is(':checked');
  297. checked = checked ? 1 : 0;
  298. $data = {
  299. checked:checked
  300. };
  301. $data[csrfName] = csrfVal;
  302. selectCurrentUrl = currentUrl + '?selectall=' + checked;
  303. $.ajax({
  304. async:true,
  305. timeout: 6000,
  306. dataType: 'json',
  307. type:'post',
  308. data: $data,
  309. url:selectAllProductUrl,
  310. success:function(data, textStatus){
  311. if(data.status == 'success'){
  312. window.location.href = selectCurrentUrl;
  313. }
  314. },
  315. error:function (XMLHttpRequest, textStatus, errorThrown){}
  316. });
  317. });
  318. $(".add_coupon_submit").click(function(){
  319. coupon_code = $("#coupon_code").val();
  320. coupon_type = $(".couponType").val();
  321. coupon_url = "";
  322. if(coupon_type == 2){
  323. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/addcoupon'); ?>";
  324. }else if(coupon_type == 1){
  325. coupon_url = "<?= Yii::$service->url->getUrl('checkout/cart/cancelcoupon'); ?>";
  326. }
  327. if(!coupon_code){
  328. //alert("coupon can not empty!");
  329. }
  330. $data = {"coupon_code":coupon_code};
  331. $data[csrfName] = csrfVal;
  332. $.ajax({
  333. async:true,
  334. timeout: 6000,
  335. dataType: 'json',
  336. type: 'post',
  337. data: $data,
  338. url:coupon_url,
  339. success:function(data, textStatus){
  340. if(data.status == 'success'){
  341. window.location.href=currentUrl;
  342. }else if(data.content == 'nologin'){
  343. window.location.href="<?= Yii::$service->url->getUrl('customer/account/login'); ?>";
  344. }else{
  345. $(".coupon_add_log").html(data.content);
  346. }
  347. },
  348. error:function (XMLHttpRequest, textStatus, errorThrown){}
  349. });
  350. });
  351. });
  352. <?php $this->endBlock(); ?>
  353. <?php $this->registerJs($this->blocks['changeCartInfo'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
  354. </script>
  355. <?php // Yii::$service->page->trace->getTraceCartJsCode($trace_cart_info) // 这个改成服务端发送加入购物车数据,而不是js传递的方式 ?>