evolve_woocommerce_header_add_to_cart_fragment

The evolve evolve woocommerce header add to cart fragment function.

Description

evolve_woocommerce_header_add_to_cart_fragment( $fragments ); 

Parameters (1)

0. $fragments
The fragments.

Usage

  1. if ( !function_exists( 'evolve_woocommerce_header_add_to_cart_fragment' ) ) { 
  2. require_once '/library/woo-config.php'; 
  3.  
  4. // The fragments. 
  5. $fragments = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = evolve_woocommerce_header_add_to_cart_fragment($fragments); 
  9.  

Defined (1)

The function is defined in the following location(s).

/library/woo-config.php  
  1. function evolve_woocommerce_header_add_to_cart_fragment($fragments) { 
  2. global $woocommerce; 
  3.  
  4. ob_start(); 
  5.  
  6. $evolve_header_type = evolve_get_option('evl_header_type', 'none'); 
  7. if ($evolve_header_type == 'h1') { 
  8. ?> 
  9. <li class="cart header-cart"> 
  10. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  11. <a class="empty-cart" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  12. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  13. </a> 
  14. <div class="cart-contents"> 
  15. <div class="cart-content" style="width:180px!important;"> 
  16. <strong style="padding:7px 10px;line-height:35px;"> 
  17. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  18. </strong> 
  19. </div> 
  20. </div> 
  21.  
  22. <?php else: ?> 
  23. <a class="my-cart-link my-cart-link-active" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  24. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  25. </a> 
  26. <div class="cart-contents"> 
  27. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): //var_dump($cart_item); ?> 
  28. <div class="cart-content"> 
  29. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  30. <?php 
  31. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  32. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  33. ?> 
  34. <div class="cart-desc"> 
  35. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  36. <span class="product-quantity"> 
  37. <?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], $cart_item['quantity']); ?> 
  38. </span> 
  39. </div> 
  40. </a> 
  41. </div> 
  42. <?php endforeach; ?> 
  43. <div class="cart-checkout"> 
  44. <div class="cart-link"> 
  45. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  46. </div> 
  47. <div class="checkout-link"> 
  48. <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a> 
  49. </div> 
  50. </div> 
  51. </div><!-- /.cart-contents --> 
  52. <?php endif; //if(!$woocommerce->cart->cart_contents_count): ?> 
  53. </li><!-- /li.cart --> 
  54. <?php 
  55. $fragments['.cart.header-cart'] = ob_get_clean(); 
  56. else if ($evolve_header_type == 'h2') { 
  57. ?> 
  58. <li class="cart header-cart"> 
  59. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  60. <a class="empty-cart" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  61. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  62. </a> 
  63. <div class="cart-contents"> 
  64. <div class="cart-content" style="width:180px!important;"> 
  65. <strong style="padding:7px 10px;line-height:35px;"> 
  66. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  67. </strong> 
  68. </div> 
  69. </div> 
  70.  
  71. <?php else: ?> 
  72. <a class="my-cart-link my-cart-link-active" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  73. <?php //echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  74. </a> 
  75. <div class="cart-contents"> 
  76. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): //var_dump($cart_item); ?> 
  77. <div class="cart-content"> 
  78. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  79. <?php 
  80. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  81. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  82. ?> 
  83. <div class="cart-desc"> 
  84. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  85. <span class="product-quantity"> 
  86. <?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], $cart_item['quantity']); ?> 
  87. </span> 
  88. </div> 
  89. </a> 
  90. </div> 
  91. <?php endforeach; ?> 
  92. <div class="cart-checkout"> 
  93. <div class="cart-link"> 
  94. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  95. </div> 
  96. <div class="checkout-link"> 
  97. <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a> 
  98. </div> 
  99. </div> 
  100. </div><!-- /.cart-contents --> 
  101. <?php endif; //if(!$woocommerce->cart->cart_contents_count): ?> 
  102. </li><!-- /li.cart --> 
  103. <?php 
  104. $fragments['.cart.header-cart'] = ob_get_clean(); 
  105. else if ($evolve_header_type == 'h3') { 
  106. ?> 
  107. <li class="cart header-cart"> 
  108. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  109. <a class="empty-cart" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  110. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  111. </a> 
  112. <div class="cart-contents"> 
  113. <div class="cart-content" style="width:180px!important;"> 
  114.  
  115. <strong style="padding:7px 10px;line-height:35px;"> 
  116. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  117. </strong> 
  118. </div> 
  119. </div> 
  120.  
  121. <?php else: ?> 
  122. <a class="my-cart-link my-cart-link-active" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  123. <span><?php echo $woocommerce->cart->cart_contents_count; ?> item(s)</span> 
  124. </a> 
  125. <div class="cart-contents"> 
  126. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): //var_dump($cart_item); ?> 
  127. <div class="cart-content"> 
  128. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  129. <?php 
  130. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  131. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  132. ?> 
  133. <div class="cart-desc"> 
  134. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  135. <span class="product-quantity"> 
  136. <?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], $cart_item['quantity']); ?> 
  137. </span> 
  138. </div> 
  139. </a> 
  140. </div> 
  141.  
  142. <?php endforeach; ?> 
  143. <div class="cart-checkout"> 
  144. <div class="cart-link"> 
  145. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  146. </div> 
  147. <div class="checkout-link"> 
  148. <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a> 
  149. </div> 
  150. </div> 
  151. </div><!-- /.cart-contents --> 
  152. <?php endif; //if(!$woocommerce->cart->cart_contents_count): ?> 
  153. </li><!-- /li.cart --> 
  154. <?php 
  155. $fragments['.cart.header-cart'] = ob_get_clean(); 
  156. }else { 
  157. ?> 
  158. <li class="cart"> 
  159. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  160. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('0 Item(s)', 'evolve'); ?></a> 
  161. <div class="cart-contents"> 
  162. <div class="cart-content" style="width:180px!important;"> 
  163. <strong style="padding:7px 10px;line-height:35px;"> 
  164. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  165. </strong> 
  166. </div></div> 
  167. <?php else: ?> 
  168. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php echo $woocommerce->cart->cart_contents_count; ?> <?php _e('Item(s)', 'evolve'); ?> - <?php echo wc_price($woocommerce->cart->subtotal); ?></a> 
  169. <div class="cart-contents"> 
  170. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): ?> 
  171. <div class="cart-content"> 
  172. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  173. <?php 
  174. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  175. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  176. ?> 
  177. <div class="cart-desc"> 
  178. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  179. <span class="product-quantity"><?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], 1); ?></span> 
  180. </div> 
  181. </a> 
  182. </div> 
  183. <?php endforeach; ?> 
  184. <div class="cart-checkout"> 
  185. <div class="cart-link"><a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a></div> 
  186. <div class="checkout-link"><a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a></div> 
  187. </div> 
  188. </div> 
  189. <?php endif; ?> 
  190. </li> 
  191. <?php 
  192. $fragments['.header .cart'] = ob_get_clean(); 
  193.  
  194. ob_start(); 
  195.  
  196. return $fragments;