/library/woo-config.php

  1. <?php 
  2. /** 
  3. * Theme4Press Framework 
  4. * 
  5. * WARNING: This file is part of the Theme4Press Core Framework. 
  6. * Do not edit the core files. 
  7. * Add any modifications necessary under a child theme. 
  8. * 
  9. * @package Theme4Press/Template 
  10. * @author Theme4Press 
  11. * @link http://theme4press.com 
  12. */ 
  13. // Exit if accessed directly 
  14. if (!defined('ABSPATH')) { 
  15. die; 
  16.  
  17. if(session_id() == '' || !isset($_SESSION)) 
  18. session_start(); 
  19.  
  20. add_action('init', 'woocommerce_evolve_ordering'); 
  21.  
  22. function woocommerce_evolve_ordering() { 
  23. $woocommerce_evolve_ordering = evolve_get_option('evl_woocommerce_evolve_ordering', '0'); 
  24.  
  25. /** remove default shorting option */ 
  26. remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30); 
  27. if (!$woocommerce_evolve_ordering) { 
  28. add_action('woocommerce_before_shop_loop', 'evolve_woocommerce_catalog_ordering', 30); 
  29. add_action('woocommerce_get_catalog_ordering_args', 'evolve_woocommerce_get_catalog_ordering_args', 20); 
  30.  
  31. // Don't duplicate me! 
  32. if (!class_exists('t4pTemplateWoo')) { 
  33.  
  34. /** 
  35. * Class to apply woocommerce templates 
  36. * 
  37. * @since 4.0.0 
  38. */ 
  39. class t4pTemplateWoo { 
  40.  
  41. function __construct() { 
  42.  
  43. add_filter('woocommerce_show_page_title', array($this, 'shop_title'), 10); 
  44.  
  45. add_action('woocommerce_before_main_content', array($this, 'add_sidebar_2'), 10); 
  46.  
  47. remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); 
  48. remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); 
  49. remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0); 
  50. add_action('woocommerce_before_main_content', array($this, 'before_container'), 10); 
  51. add_action('woocommerce_after_main_content', array($this, 'after_container'), 10); 
  52. add_action('woocommerce_before_main_content', array($this, 'shop_breadcrumb'), 20, 0); 
  53.  
  54. remove_action('woocommerce_sidebar', 'woocommerce_get_sidebar', 10); 
  55. add_action('woocommerce_sidebar', array($this, 'add_sidebar'), 10); 
  56.  
  57. /** 
  58. * Products Loop 
  59. */ 
  60. add_action('woocommerce_after_shop_loop_item', array($this, 'before_shop_item_buttons'), 9); 
  61. add_action('woocommerce_after_shop_loop_item', array($this, 'after_shop_item_buttons'), 11); 
  62.  
  63. /** 
  64. * Single Product Page 
  65. */ 
  66. add_action('woocommerce_single_product_summary', array($this, 'add_product_border'), 19); 
  67. remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10); 
  68. remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10); 
  69. add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10); 
  70. add_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 11); 
  71.  
  72. /** 
  73. * WooCommerce 2.3 Remove extra checkout button 
  74. */ 
  75. remove_action('woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 10); 
  76. // Backwards compatability to 2.2 
  77. add_filter('woocommerce_template_path', array($this, 'backwards_compatability')); 
  78.  
  79. // end __construct(); 
  80.  
  81. /** 
  82. * Filter method to modify path to WooCommerce files if WooCommerce is a version less than 2.3 
  83. * 
  84. * @since 3.7.2 
  85. * @return relative path of WooCommerce template files within the theme 
  86. */ 
  87. function backwards_compatability($path) { 
  88. if (!self::is_wc_version_gte_2_3()) { 
  89. $path = "woocommerce/compatability/2.2/"; 
  90. return $path; 
  91.  
  92. /** 
  93. * Helper method to get the version of the currently installed WooCommerce 
  94. * 
  95. * @since 3.7.2 
  96. * @return string woocommerce version number or null 
  97. */ 
  98. private static function get_wc_version() { 
  99. return defined('WC_VERSION') && WC_VERSION ? WC_VERSION : null; 
  100.  
  101. /** 
  102. * Returns true if the installed version of WooCommerce is 2.3 or greater 
  103. * 
  104. * @since 3.7.2 
  105. * @return boolean true if the installed version of WooCommerce is 2.3 or greater 
  106. */ 
  107. public static function is_wc_version_gte_2_3() { 
  108. return self::get_wc_version() && version_compare(self::get_wc_version(), '2.3', '>='); 
  109.  
  110. function before_container() { 
  111. global $post; 
  112. global $wp_query; 
  113.  
  114. if (is_shop()) { 
  115. $pageID = get_option('woocommerce_shop_page_id'); 
  116. } elseif (class_exists('Woocommerce') && (is_product_category() || is_product_tag())) { 
  117. $pageID = ''; 
  118. } else { 
  119. $pageID = $post->ID; 
  120.  
  121. $custom_fields = get_post_custom_values('_wp_page_template', $pageID); 
  122. if (is_array($custom_fields) && !empty($custom_fields)) { 
  123. $page_template = $custom_fields[0]; 
  124. } else { 
  125. $page_template = ''; 
  126.  
  127. $evolve_layout = evolve_get_option('evl_layout', '2cl'); 
  128. $evolve_post_layout = evolve_get_option('evl_post_layout', 'two'); 
  129. $evolve_opt1_width_content = evolve_get_option('evl_opt1_width_content', '8'); 
  130. $evolve_opt2_width_content = evolve_get_option('evl_opt2_width_content', '6'); 
  131.  
  132. $layout_css = ''; 
  133. echo'<div id="primary" class="'; 
  134.  
  135. if ($evolve_layout == "1c") { 
  136. $layout_css.= ' col-md-12'; 
  137. } else { 
  138.  
  139. if (($evolve_layout == "2cr" && ($evolve_post_layout == "two") || $evolve_layout == "2cl" && ($evolve_post_layout == "two"))) { 
  140. $layout_css.= 'col-md-12 col-sm-' . $evolve_opt1_width_content . ' col-md-' . $evolve_opt1_width_content . ''; 
  141.  
  142. if (($evolve_layout == "3cm" || $evolve_layout == "3cl" || $evolve_layout == "3cr")) { 
  143. $layout_css.= 'col-md-12 col-sm-' . $evolve_opt2_width_content . ' col-md-' . $evolve_opt2_width_content . ''; 
  144. } else { 
  145. $layout_css.= 'col-md-12 col-sm-' . $evolve_opt1_width_content . ' col-md-' . $evolve_opt1_width_content . ''; 
  146.  
  147. if (is_single() || is_page()) { 
  148. $layout_css.= ' col-single'; 
  149.  
  150. echo $layout_css; 
  151. echo '">'; 
  152.  
  153. function shop_title() { 
  154. return false; 
  155.  
  156. function after_container() { 
  157. echo '</div>'; 
  158.  
  159. function add_sidebar_2() { 
  160. global $wp_query, $post; 
  161.  
  162. if (is_shop()) { 
  163. $pageID = get_option('woocommerce_shop_page_id'); 
  164. } elseif (class_exists('Woocommerce') && (is_product_category() || is_product_tag())) { 
  165. $pageID = ''; 
  166. } else { 
  167. $pageID = $post->ID; 
  168.  
  169. $get_sidebar = false; 
  170.  
  171. $evolve_layout = evolve_get_option('evl_layout', '2cl'); 
  172. $evolve_opt2_width_sidebar2 = evolve_get_option('evl_opt2_width_sidebar2', '3'); 
  173.  
  174. if ($evolve_layout == "3cm" || $evolve_layout == "3cl" || $evolve_layout == "3cr") { 
  175. $get_sidebar = true; 
  176.  
  177. $sidebar_css = ''; 
  178.  
  179. if ($get_sidebar) { 
  180. //get_sidebar('2'); 
  181. if (class_exists('Woocommerce')) { 
  182. if (is_cart() || is_checkout() || is_account_page() || (get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id')))) { 
  183. $sidebar_css = ''; 
  184.  
  185. echo '<div id="secondary-2" class="aside '; 
  186.  
  187. //use PHP switch statement, is easier to understand. 
  188. switch ($evolve_layout): 
  189. case "1c": 
  190. //do nothing 
  191. break; 
  192. case "2cl": 
  193. //do nothing 
  194. break; 
  195. case "2cr": 
  196. //do nothing 
  197. break; 
  198. case "3cm": 
  199. $sidebar_css = 'col-xs-12 col-sm-' . $evolve_opt2_width_sidebar2 . ' col-md-' . $evolve_opt2_width_sidebar2 . ''; 
  200. break; 
  201. case "3cl": 
  202. $sidebar_css = 'col-xs-12 col-sm-' . $evolve_opt2_width_sidebar2 . ' col-md-' . $evolve_opt2_width_sidebar2 . ''; 
  203. break; 
  204. case "3cr": 
  205. $sidebar_css = 'col-xs-12 col-sm-' . $evolve_opt2_width_sidebar2 . ' col-md-' . $evolve_opt2_width_sidebar2 . ''; 
  206. break; 
  207. endswitch; 
  208.  
  209. echo $sidebar_css.'"'; 
  210.  
  211. echo '>'; 
  212.  
  213. wp_reset_query(); 
  214.  
  215. if (dynamic_sidebar('sidebar-2')) : 
  216. endif; 
  217.  
  218. echo '</div>'; 
  219.  
  220. function add_sidebar() { 
  221. global $post; 
  222.  
  223. if (is_shop()) { 
  224. $pageID = get_option('woocommerce_shop_page_id'); 
  225. } elseif (class_exists('Woocommerce') && (is_product_category() || is_product_tag())) { 
  226. $pageID = ''; 
  227. } else { 
  228. $pageID = $post->ID; 
  229.  
  230. $evolve_layout = evolve_get_option('evl_layout', '2cl'); 
  231. $evolve_opt1_width_sidebar1 = evolve_get_option('evl_opt1_width_sidebar1', '4'); 
  232. $evolve_opt2_width_sidebar1 = evolve_get_option('evl_opt2_width_sidebar1', '3'); 
  233.  
  234. $sidebar_css = ''; 
  235.  
  236. if (class_exists('Woocommerce')) { 
  237. if (is_cart() || is_checkout() || is_account_page() || (get_option('woocommerce_thanks_page_id') && is_page(get_option('woocommerce_thanks_page_id')))) { 
  238. $sidebar_css = ''; 
  239.  
  240. echo '<div id="secondary" class="aside '; 
  241.  
  242. //use PHP switch statement, is easier to understand. 
  243. switch ($evolve_layout): 
  244. case "1c": 
  245. $sidebar_css = ''; 
  246. echo '"'; 
  247. echo "style='display:none;'"; 
  248. break; 
  249. case "2cl": 
  250. $sidebar_css = 'col-sm-' . $evolve_opt1_width_sidebar1 . ' col-md-' . $evolve_opt1_width_sidebar1 . ''; 
  251. break; 
  252. case "2cr": 
  253. $sidebar_css = 'col-sm-' . $evolve_opt1_width_sidebar1 . ' col-md-' . $evolve_opt1_width_sidebar1 . ''; 
  254. break; 
  255. case "3cm": 
  256. $sidebar_css = 'col-xs-12 col-sm-' . $evolve_opt2_width_sidebar1 . ' col-md-' . $evolve_opt2_width_sidebar1 . ''; 
  257. break; 
  258. case "3cl": 
  259. $sidebar_css = 'col-xs-12 col-sm-' . $evolve_opt2_width_sidebar1 . ' col-md-' . $evolve_opt2_width_sidebar1 . ''; 
  260. break; 
  261. case "3cr": 
  262. $sidebar_css = 'col-xs-12 col-sm-' . $evolve_opt2_width_sidebar1 . ' col-md-' . $evolve_opt2_width_sidebar1 . ''; 
  263. break; 
  264. endswitch; 
  265.  
  266. if ($evolve_layout != '1c') { 
  267. echo $sidebar_css.'"'; 
  268. echo '>'; 
  269.  
  270. wp_reset_query(); 
  271.  
  272. if (!dynamic_sidebar('sidebar-1')) : 
  273. endif; 
  274.  
  275. echo '</div>'; 
  276.  
  277. function before_shop_item_buttons() { 
  278. echo '<div class="product-buttons"><div class="product-buttons-container clearfix">'; 
  279.  
  280. function after_shop_item_buttons() { 
  281. echo '</div></div>'; 
  282.  
  283. function add_product_border() { 
  284. echo '<div class="clear"></div><div class="product-border"></div>'; 
  285.  
  286. function shop_breadcrumb() { 
  287. $evolve_breadcrumbs = evolve_get_option('evl_breadcrumbs', '1'); 
  288. $evolve_pagetitlebar_layout = evolve_get_option('evl_pagetitlebar_layout', '0'); 
  289. if ($evolve_breadcrumbs == "1" && $evolve_pagetitlebar_layout == '0'): 
  290. woocommerce_breadcrumb(); 
  291. endif; 
  292.  
  293.  
  294. // end t4pTemplateWoo() class 
  295. new t4pTemplateWoo(); 
  296.  
  297. add_filter('get_product_search_form', 'evolve_product_search_form'); 
  298.  
  299. function evolve_product_search_form($form) { 
  300. $form = '<form role="search" method="get" id="searchform" action="' . esc_url(home_url('/')) . '"> 
  301. <div> 
  302. <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __('Search...', 'evolve') . '" /> 
  303. <input type="hidden" name="post_type" value="product" /> 
  304. </div> 
  305. </form>'; 
  306.  
  307. return $form; 
  308.  
  309. remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); 
  310.  
  311. /** 
  312. * Category page show shorting order 
  313. */ 
  314.  
  315. function evolve_woocommerce_catalog_ordering() { 
  316.  
  317. $woo_items = evolve_get_option('evl_woo_items', '12'); 
  318.  
  319. if (isset($_SERVER['QUERY_STRING'])) { 
  320.  
  321. parse_str($_SERVER['QUERY_STRING'], $params); 
  322.  
  323. $query_string = '?' . $_SERVER['QUERY_STRING']; 
  324. } else { 
  325. $query_string = ''; 
  326.  
  327. // replace it with theme option 
  328. if ($woo_items) { 
  329. $per_page = $woo_items; 
  330. } else { 
  331. $per_page = 12; 
  332.  
  333. $pob = !empty($params['product_orderby']) ? $params['product_orderby'] : 'default'; 
  334. $po = !empty($params['product_order']) ? $params['product_order'] : 'asc'; 
  335. $pc = !empty($params['product_count']) ? $params['product_count'] : $per_page; 
  336.  
  337. $html = ''; 
  338. $html .= '<div class="catalog-ordering clearfix">'; 
  339.  
  340. $html .= '<div class="orderby-order-container">'; 
  341.  
  342. $html .= '<ul class="orderby order-dropdown">'; 
  343. $html .= '<li>'; 
  344. $html .= '<span class="current-li"><span class="current-li-content"><a>' . __('Sort by', 'evolve') . ' <strong>' . __('Default Order', 'evolve') . '</strong></a></span></span>'; 
  345. $html .= '<ul>'; 
  346. $html .= '<li class="' . (($pob == 'default') ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_orderby', 'default') . '">' . __('Sort by', 'evolve') . ' <strong>' . __('Default Order', 'evolve') . '</strong></a></li>'; 
  347. $html .= '<li class="' . (($pob == 'name') ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_orderby', 'name') . '">' . __('Sort by', 'evolve') . ' <strong>' . __('Name', 'evolve') . '</strong></a></li>'; 
  348. $html .= '<li class="' . (($pob == 'price') ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_orderby', 'price') . '">' . __('Sort by', 'evolve') . ' <strong>' . __('Price', 'evolve') . '</strong></a></li>'; 
  349. $html .= '<li class="' . (($pob == 'date') ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_orderby', 'date') . '">' . __('Sort by', 'evolve') . ' <strong>' . __('Date', 'evolve') . '</strong></a></li>'; 
  350. $html .= '<li class="' . (($pob == 'popularity') ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_orderby', 'popularity') . '">' . __('Sort by', 'evolve') . ' <strong>' . __('Popularity', 'evolve') . '</strong></a></li>'; 
  351. $html .= '<li class="' . (($pob == 'rating') ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_orderby', 'rating') . '">' . __('Sort by', 'evolve') . ' <strong>' . __('Rating', 'evolve') . '</strong></a></li>'; 
  352. $html .= '</ul>'; 
  353. $html .= '</li>'; 
  354. $html .= '</ul>'; 
  355.  
  356.  
  357. $html .= '<ul class="order">'; 
  358. if ($po == 'desc'): 
  359. $html .= '<li class="desc"><a href="' . t4p_addURLParameter($query_string, 'product_order', 'asc') . '"><i class="t4p-icon t4p-icon-chevron-up"></i></a></li>'; 
  360. endif; 
  361. if ($po == 'asc'): 
  362. $html .= '<li class="asc"><a href="' . t4p_addURLParameter($query_string, 'product_order', 'desc') . '"><i class="t4p-icon t4p-icon-chevron-down"></i></a></li>'; 
  363. endif; 
  364. $html .= '</ul>'; 
  365.  
  366. $html .= '</div>'; 
  367.  
  368. $html .= '<ul class="sort-count order-dropdown">'; 
  369. $html .= '<li>'; 
  370. $html .= '<span class="current-li"><a>' . __('Show', 'evolve') . ' <strong>' . $per_page . ' ' . __(' Products', 'evolve') . '</strong></a></span>'; 
  371. $html .= '<ul>'; 
  372. $html .= '<li class="' . (($pc == $per_page) ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_count', $per_page) . '">' . __('Show', 'evolve') . ' <strong>' . $per_page . ' ' . __('Products', 'evolve') . '</strong></a></li>'; 
  373. $html .= '<li class="' . (($pc == $per_page * 2) ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_count', $per_page * 2) . '">' . __('Show', 'evolve') . ' <strong>' . ($per_page * 2) . ' ' . __('Products', 'evolve') . '</strong></a></li>'; 
  374. $html .= '<li class="' . (($pc == $per_page * 3) ? 'current' : '') . '"><a href="' . t4p_addURLParameter($query_string, 'product_count', $per_page * 3) . '">' . __('Show', 'evolve') . ' <strong>' . ($per_page * 3) . ' ' . __('Products', 'evolve') . '</strong></a></li>'; 
  375. $html .= '</ul>'; 
  376. $html .= '</li>'; 
  377. $html .= '</ul>'; 
  378. $html .= '</div>'; 
  379.  
  380. echo $html; 
  381.  
  382. function evolve_woocommerce_get_catalog_ordering_args($args) { 
  383. global $woocommerce; 
  384.  
  385. if (isset($_SERVER['QUERY_STRING'])) { 
  386.  
  387. parse_str($_SERVER['QUERY_STRING'], $params); 
  388.  
  389. $pob = !empty($params['product_orderby']) ? $params['product_orderby'] : 'default'; 
  390. $po = !empty($params['product_order']) ? $params['product_order'] : 'asc'; 
  391.  
  392. switch ($pob) { 
  393. case 'date': 
  394. $orderby = 'date'; 
  395. $order = 'asc'; 
  396. $meta_key = ''; 
  397. break; 
  398. case 'price': 
  399. $orderby = 'meta_value_num'; 
  400. $order = 'asc'; 
  401. $meta_key = '_price'; 
  402. break; 
  403. case 'popularity': 
  404. $orderby = 'meta_value_num'; 
  405. $order = 'asc'; 
  406. $meta_key = 'total_sales'; 
  407. break; 
  408. case 'rating': 
  409. $orderby = 'meta_value_num'; 
  410. $order = 'asc'; 
  411. $meta_key = 'average_rating'; 
  412. break; 
  413. case 'name': 
  414. $orderby = 'title'; 
  415. $order = 'asc'; 
  416. $meta_key = ''; 
  417. break; 
  418. case 'default': 
  419. return $args; 
  420. break; 
  421.  
  422. switch ($po) { 
  423. case 'desc': 
  424. $order = 'desc'; 
  425. break; 
  426. case 'asc': 
  427. $order = 'asc'; 
  428. break; 
  429. default: 
  430. $order = 'asc'; 
  431. break; 
  432.  
  433. $args['orderby'] = $orderby; 
  434. $args['order'] = $order; 
  435. $args['meta_key'] = $meta_key; 
  436.  
  437. if ($pob == 'rating') { 
  438. $args['orderby'] = 'menu_order title'; 
  439. $args['order'] = $po == 'desc' ? 'desc' : 'asc'; 
  440. $args['order'] = strtoupper($args['order']); 
  441. $args['meta_key'] = ''; 
  442.  
  443. add_filter('posts_clauses', 't4p_order_by_rating_post_clauses'); 
  444.  
  445. return $args; 
  446.  
  447. /** 
  448. * t4p_order_by_rating_post_clauses function. 
  449. * 
  450. * @access public 
  451. * @param array $args 
  452. * @return array 
  453. */ 
  454. function t4p_order_by_rating_post_clauses($args) { 
  455. global $wpdb; 
  456.  
  457. $args['fields'] .= ", AVG( $wpdb->commentmeta.meta_value ) as average_rating "; 
  458.  
  459. $args['where'] .= " AND ( $wpdb->commentmeta.meta_key = 'rating' OR $wpdb->commentmeta.meta_key IS null ) "; 
  460.  
  461. $args['join'] .= " 
  462. LEFT OUTER JOIN $wpdb->comments ON($wpdb->posts.ID = $wpdb->comments.comment_post_ID) 
  463. LEFT JOIN $wpdb->commentmeta ON($wpdb->comments.comment_ID = $wpdb->commentmeta.comment_id) 
  464. "; 
  465.  
  466. if (isset($_SERVER['QUERY_STRING'])) { 
  467. parse_str($_SERVER['QUERY_STRING'], $params); 
  468.  
  469. $order = !empty($params['product_order']) ? $params['product_order'] : 'desc'; 
  470. $order = strtoupper($order); 
  471.  
  472. $args['orderby'] = "sum_of_comments_approved DESC, average_rating {$order}, $wpdb->posts.post_date DESC"; 
  473.  
  474. $args['groupby'] = "$wpdb->posts.ID"; 
  475.  
  476. return $args; 
  477.  
  478. add_filter('loop_shop_per_page', 'evolve_loop_shop_per_page'); 
  479.  
  480. function evolve_loop_shop_per_page() { 
  481.  
  482. $woo_items = evolve_get_option('evl_woo_items', '12'); 
  483.  
  484. if (isset($_SERVER['QUERY_STRING'])) { 
  485. parse_str($_SERVER['QUERY_STRING'], $params); 
  486.  
  487. if ($woo_items) { 
  488. $per_page = $woo_items; 
  489. } else { 
  490. $per_page = 12; 
  491.  
  492. $pc = !empty($params['product_count']) ? $params['product_count'] : $per_page; 
  493.  
  494. return $pc; 
  495.  
  496. add_action('woocommerce_before_shop_loop_item_title', 'evolve_woocommerce_thumbnail', 10); 
  497. remove_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); 
  498.  
  499. function evolve_woocommerce_thumbnail() { 
  500. global $product, $woocommerce; 
  501.  
  502. $items_in_cart = array(); 
  503.  
  504. if ($woocommerce->cart->get_cart() && is_array($woocommerce->cart->get_cart())) { 
  505. foreach ($woocommerce->cart->get_cart() as $cart) { 
  506. $items_in_cart[] = $cart['product_id']; 
  507.  
  508. $id = get_the_ID(); 
  509. $in_cart = in_array($id, $items_in_cart); 
  510. $size = 'shop_catalog'; 
  511.  
  512. $gallery = get_post_meta($id, '_product_image_gallery', true); 
  513. $attachment_image = ''; 
  514. if (!empty($gallery)) { 
  515. $gallery = explode(', ', $gallery); 
  516. $first_image_id = $gallery[0]; 
  517. $attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image')); 
  518. $thumb_image = get_the_post_thumbnail($id, $size); 
  519.  
  520. if ($attachment_image) { 
  521. $classes = 'crossfade-images'; 
  522. } else { 
  523. $classes = ''; 
  524.  
  525. echo '<span class="' . $classes . '">'; 
  526. echo $attachment_image; 
  527. echo $thumb_image; 
  528. if ($in_cart) { 
  529. echo '<span class="cart-loading"><i class="t4p-icon t4p-icon-ok"></i></span>'; 
  530. } else { 
  531. echo '<span class="cart-loading"><i class="t4p-icon t4p-icon-repeat"></i></span>'; 
  532. echo '<span class="show_details_button">' . __('Show details', 'evolve') . '</span>'; 
  533. echo '</span>'; 
  534.  
  535. add_filter('add_to_cart_fragments', 'evolve_woocommerce_header_add_to_cart_fragment'); 
  536.  
  537. function evolve_woocommerce_header_add_to_cart_fragment($fragments) { 
  538. global $woocommerce; 
  539.  
  540. ob_start(); 
  541.  
  542. $evolve_header_type = evolve_get_option('evl_header_type', 'none'); 
  543. if ($evolve_header_type == 'h1') { 
  544. ?> 
  545. <li class="cart header-cart"> 
  546. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  547. <a class="empty-cart" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  548. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  549. </a> 
  550. <div class="cart-contents"> 
  551. <div class="cart-content" style="width:180px!important;"> 
  552. <strong style="padding:7px 10px;line-height:35px;"> 
  553. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  554. </strong> 
  555. </div> 
  556. </div> 
  557.  
  558. <?php else: ?> 
  559. <a class="my-cart-link my-cart-link-active" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  560. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  561. </a> 
  562. <div class="cart-contents"> 
  563. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): //var_dump($cart_item); ?> 
  564. <div class="cart-content"> 
  565. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  566. <?php 
  567. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  568. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  569. ?> 
  570. <div class="cart-desc"> 
  571. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  572. <span class="product-quantity"> 
  573. <?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], $cart_item['quantity']); ?> 
  574. </span> 
  575. </div> 
  576. </a> 
  577. </div> 
  578. <?php endforeach; ?> 
  579. <div class="cart-checkout"> 
  580. <div class="cart-link"> 
  581. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  582. </div> 
  583. <div class="checkout-link"> 
  584. <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a> 
  585. </div> 
  586. </div> 
  587. </div><!-- /.cart-contents --> 
  588. <?php endif; //if(!$woocommerce->cart->cart_contents_count): ?> 
  589. </li><!-- /li.cart --> 
  590. <?php 
  591. $fragments['.cart.header-cart'] = ob_get_clean(); 
  592. else if ($evolve_header_type == 'h2') { 
  593. ?> 
  594. <li class="cart header-cart"> 
  595. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  596. <a class="empty-cart" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  597. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  598. </a> 
  599. <div class="cart-contents"> 
  600. <div class="cart-content" style="width:180px!important;"> 
  601. <strong style="padding:7px 10px;line-height:35px;"> 
  602. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  603. </strong> 
  604. </div> 
  605. </div> 
  606.  
  607. <?php else: ?> 
  608. <a class="my-cart-link my-cart-link-active" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  609. <?php //echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  610. </a> 
  611. <div class="cart-contents"> 
  612. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): //var_dump($cart_item); ?> 
  613. <div class="cart-content"> 
  614. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  615. <?php 
  616. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  617. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  618. ?> 
  619. <div class="cart-desc"> 
  620. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  621. <span class="product-quantity"> 
  622. <?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], $cart_item['quantity']); ?> 
  623. </span> 
  624. </div> 
  625. </a> 
  626. </div> 
  627. <?php endforeach; ?> 
  628. <div class="cart-checkout"> 
  629. <div class="cart-link"> 
  630. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  631. </div> 
  632. <div class="checkout-link"> 
  633. <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a> 
  634. </div> 
  635. </div> 
  636. </div><!-- /.cart-contents --> 
  637. <?php endif; //if(!$woocommerce->cart->cart_contents_count): ?> 
  638. </li><!-- /li.cart --> 
  639. <?php 
  640. $fragments['.cart.header-cart'] = ob_get_clean(); 
  641. else if ($evolve_header_type == 'h3') { 
  642. ?> 
  643. <li class="cart header-cart"> 
  644. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  645. <a class="empty-cart" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  646. <?php echo wc_price($woocommerce->cart->cart_contents_total); ?> 
  647. </a> 
  648. <div class="cart-contents"> 
  649. <div class="cart-content" style="width:180px!important;"> 
  650.  
  651. <strong style="padding:7px 10px;line-height:35px;"> 
  652. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  653. </strong> 
  654. </div> 
  655. </div> 
  656.  
  657. <?php else: ?> 
  658. <a class="my-cart-link my-cart-link-active" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"> 
  659. <span><?php echo $woocommerce->cart->cart_contents_count; ?> item(s)</span> 
  660. </a> 
  661. <div class="cart-contents"> 
  662. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): //var_dump($cart_item); ?> 
  663. <div class="cart-content"> 
  664. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  665. <?php 
  666. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  667. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  668. ?> 
  669. <div class="cart-desc"> 
  670. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  671. <span class="product-quantity"> 
  672. <?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], $cart_item['quantity']); ?> 
  673. </span> 
  674. </div> 
  675. </a> 
  676. </div> 
  677.  
  678. <?php endforeach; ?> 
  679. <div class="cart-checkout"> 
  680. <div class="cart-link"> 
  681. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  682. </div> 
  683. <div class="checkout-link"> 
  684. <a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a> 
  685. </div> 
  686. </div> 
  687. </div><!-- /.cart-contents --> 
  688. <?php endif; //if(!$woocommerce->cart->cart_contents_count): ?> 
  689. </li><!-- /li.cart --> 
  690. <?php 
  691. $fragments['.cart.header-cart'] = ob_get_clean(); 
  692. }else { 
  693. ?> 
  694. <li class="cart"> 
  695. <?php if (!$woocommerce->cart->cart_contents_count): ?> 
  696. <a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('0 Item(s)', 'evolve'); ?></a> 
  697. <div class="cart-contents"> 
  698. <div class="cart-content" style="width:180px!important;"> 
  699. <strong style="padding:7px 10px;line-height:35px;"> 
  700. <?php _e('Your cart is currently empty.', 'evolve'); ?> 
  701. </strong> 
  702. </div></div> 
  703. <?php else: ?> 
  704. <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> 
  705. <div class="cart-contents"> 
  706. <?php foreach ($woocommerce->cart->cart_contents as $cart_item): ?> 
  707. <div class="cart-content"> 
  708. <a href="<?php echo get_permalink($cart_item['product_id']); ?>"> 
  709. <?php 
  710. $thumbnail_id = ($cart_item['variation_id']) ? $cart_item['variation_id'] : $cart_item['product_id']; 
  711. echo get_the_post_thumbnail($thumbnail_id, 'recent-works-thumbnail'); 
  712. ?> 
  713. <div class="cart-desc"> 
  714. <span class="cart-title"><?php echo $cart_item['data']->post->post_title; ?></span> 
  715. <span class="product-quantity"><?php echo $cart_item['quantity']; ?> x <?php echo $woocommerce->cart->get_product_subtotal($cart_item['data'], 1); ?></span> 
  716. </div> 
  717. </a> 
  718. </div> 
  719. <?php endforeach; ?> 
  720. <div class="cart-checkout"> 
  721. <div class="cart-link"><a href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a></div> 
  722. <div class="checkout-link"><a href="<?php echo get_permalink(get_option('woocommerce_checkout_page_id')); ?>"><?php _e('Checkout', 'evolve'); ?></a></div> 
  723. </div> 
  724. </div> 
  725. <?php endif; ?> 
  726. </li> 
  727. <?php 
  728. $fragments['.header .cart'] = ob_get_clean(); 
  729.  
  730. ob_start(); 
  731.  
  732. return $fragments; 
  733.  
  734. add_action('woocommerce_after_single_product_summary', 'evolve_woocommerce_after_single_product_summary', 15); 
  735.  
  736. function evolve_woocommerce_after_single_product_summary() { 
  737.  
  738. $woocommerce_social_links = evolve_get_option('evl_woocommerce_social_links', '1'); 
  739. $nofollow_social_links = evolve_get_option('evl_nofollow_social_links', '0'); 
  740. $social = ''; 
  741. $nofollow = ''; 
  742. if ($nofollow_social_links) { 
  743. $nofollow = ' rel="nofollow"'; 
  744. if ($woocommerce_social_links): 
  745.  
  746. $social .= '<ul class="social-share"> 
  747. <li class="facebook"> 
  748. <a target="_blank" class="tipsytext" title="' . __('Share On', 'evolve') . ' Facebook" href="http://www.facebook.com/sharer.php?m2w&s=100&p[url]=' . get_permalink() . '&p[title]=' . wp_strip_all_tags(get_the_title(), true) . '" target="_blank"' . $nofollow . '> 
  749. <i class="t4p-icon-social-facebook"></i>  
  750. </a> 
  751. </li> 
  752. <li class="twitter"> 
  753. <a target="_blank" class="tipsytext" title="' . __('Share On', 'evolve') . ' Twitter" href="https://twitter.com/share?text=' . wp_strip_all_tags(get_the_title(), true) . ' ' . get_permalink() . '" target="_blank"' . $nofollow . '> 
  754. <i class="t4p-icon-social-twitter"></i>  
  755. </a> 
  756. </li> 
  757. <li class="pinterest">'; 
  758. $full_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); 
  759. $social .= '<a target="_blank" class="tipsytext" title="' . __('Pin to', 'evolve') . ' Pinterest" href="http://pinterest.com/pin/create/button/?url=' . urlencode(wp_strip_all_tags(get_the_title(), true)) . '&description=' . urlencode(get_the_title()) . '&media=' . urlencode($full_image[0]) . '" target="_blank"' . $nofollow . '> 
  760. <i class="t4p-icon-social-pinterest"></i>  
  761. </a> 
  762. </li> 
  763. <li class="email"> 
  764. <a target="_blank" class="tipsytext" title="' . __('Email to a Friend', 'evolve') . '" href="mailto:?subject=' . wp_strip_all_tags(get_the_title(), true) . '&body=' . get_permalink() . '"> 
  765. <i class="t4p-icon-social-envelope-o"></i>  
  766. </a> 
  767. </li> 
  768. </ul>'; 
  769. endif; 
  770. $social .= '<div style="clear:both;"></div>'; 
  771.  
  772. echo $social; 
  773.  
  774. remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20); 
  775. add_action('woocommerce_after_single_product_summary', 'evolve_woocommerce_output_related_products', 15); 
  776.  
  777. function evolve_woocommerce_output_related_products() { 
  778. $args = array( 
  779. 'posts_per_page' => 4,  
  780. 'columns' => 4,  
  781. 'orderby' => 'rand' 
  782. ); 
  783.  
  784. woocommerce_related_products(apply_filters('woocommerce_output_related_products_args', $args)); 
  785.  
  786. /** variations hooks */ 
  787.  
  788.  
  789. /** end variations hooks */ 
  790.  
  791. /** cart hooks */ 
  792. add_action('woocommerce_before_cart_table', 'evolve_woocommerce_before_cart_table', 20); 
  793.  
  794. function evolve_woocommerce_before_cart_table($args) { 
  795. global $woocommerce; 
  796.  
  797. $html = '<div class="woocommerce-content-box full-width clearfix">'; 
  798.  
  799. $html .= '<h2>' . sprintf(__('You Have %d Items In Your Cart', 'evolve'), $woocommerce->cart->cart_contents_count) . '</h2>'; 
  800.  
  801. echo $html; 
  802.  
  803. add_action('woocommerce_after_cart_table', 'evolve_woocommerce_after_cart_table', 20); 
  804.  
  805. function evolve_woocommerce_after_cart_table($args) { 
  806. $html = '</div>'; 
  807.  
  808. echo $html; 
  809.  
  810. function woocommerce_cross_sell_display($posts_per_page = 3, $columns = 3, $orderby = 'rand') { 
  811. wc_get_template('cart/cross-sells.php', array( 
  812. 'posts_per_page' => $posts_per_page,  
  813. 'orderby' => $orderby,  
  814. 'columns' => $columns 
  815. )); 
  816.  
  817. function cart_shipping_calc() { 
  818. global $woocommerce; 
  819.  
  820. if (get_option('woocommerce_enable_shipping_calc') === 'no' || !WC()->cart->needs_shipping()) { 
  821. return; 
  822.  
  823. do_action('woocommerce_before_shipping_calculator'); 
  824. ?> 
  825.  
  826. <div class="shipping_calculator" action="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" method="post"> 
  827.  
  828. <h2><?php _e('Calculate Shipping', 'evolve'); ?></h2> 
  829.  
  830. <div class="evolve-shipping-calculator-form"> 
  831.  
  832. <p class="form-row form-row-wide"> 
  833. <select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state"> 
  834. <option value=""><?php _e('Select a country…', 'evolve'); ?></option> 
  835. <?php 
  836. foreach (WC()->countries->get_shipping_countries() as $key => $value) 
  837. echo '<option value="' . esc_attr($key) . '"' . selected(WC()->customer->get_shipping_country(), esc_attr($key), false) . '>' . esc_html($value) . '</option>'; 
  838. ?> 
  839. </select> 
  840. </p> 
  841.  
  842. <p class="form-row form-row-wide"> 
  843. <?php 
  844. $current_cc = WC()->customer->get_shipping_country(); 
  845. $current_r = WC()->customer->get_shipping_state(); 
  846. $states = WC()->countries->get_states($current_cc); 
  847.  
  848. // Hidden Input 
  849. if (is_array($states) && empty($states)) { 
  850. ?><input type="hidden" name="calc_shipping_state" id="calc_shipping_state" placeholder="<?php _e('State / county', 'evolve'); ?>" /><?php 
  851. // Dropdown Input 
  852. } elseif (is_array($states)) { 
  853. ?><span> 
  854. <select name="calc_shipping_state" id="calc_shipping_state" placeholder="<?php _e('State / county', 'evolve'); ?>"> 
  855. <option value=""><?php _e('Select a state…', 'evolve'); ?></option> 
  856. <?php 
  857. foreach ($states as $ckey => $cvalue) 
  858. echo '<option value="' . esc_attr($ckey) . '" ' . selected($current_r, $ckey, false) . '>' . esc_html( $cvalue ) . '</option>'; 
  859. ?> 
  860. </select> 
  861. </span><?php 
  862. // Standard Input 
  863. } else { 
  864. ?><input type="text" class="input-text" value="<?php echo esc_attr($current_r); ?>" placeholder="<?php _e('State / county', 'evolve'); ?>" name="calc_shipping_state" id="calc_shipping_state" /><?php 
  865. ?> 
  866. </p> 
  867.  
  868. <?php if (apply_filters('woocommerce_shipping_calculator_enable_city', false)) : ?> 
  869.  
  870. <p class="form-row form-row-wide"> 
  871. <input type="text" class="input-text" value="<?php echo esc_attr(WC()->customer->get_shipping_city()); ?>" placeholder="<?php _e('City', 'evolve'); ?>" name="calc_shipping_city" id="calc_shipping_city" /> 
  872. </p> 
  873.  
  874. <?php 
  875. endif; 
  876.  
  877. if (apply_filters('woocommerce_shipping_calculator_enable_postcode', true)) : 
  878. ?> 
  879.  
  880. <p class="form-row form-row-wide"> 
  881. <input type="text" class="input-text" value="<?php echo esc_attr(WC()->customer->get_shipping_postcode()); ?>" placeholder="<?php _e('Postcode / Zip', 'evolve'); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" /> 
  882. </p> 
  883.  
  884. <?php endif; ?> 
  885.  
  886. <p><button type="submit" name="calc_shipping" value="1" class="button"><?php _e('Update Totals', 'evolve'); ?></button></p> 
  887.  
  888. <?php wp_nonce_field('woocommerce-cart'); ?> 
  889. </div> 
  890. </div> 
  891.  
  892. <?php 
  893. do_action('woocommerce_after_shipping_calculator'); 
  894.  
  895. add_action('woocommerce_cart_collaterals', 'evolve_woocommerce_cart_collaterals'); 
  896.  
  897. function evolve_woocommerce_cart_collaterals($args) { 
  898. global $woocommerce; 
  899. ?> 
  900.  
  901. <div class="shipping-coupon"> 
  902.  
  903. <?php 
  904. echo cart_shipping_calc(); 
  905.  
  906. if (WC()->cart->coupons_enabled()) { 
  907. ?> 
  908. <div class="coupon"> 
  909.  
  910. <h2><?php _e('Have A Promotional Code?', 'evolve'); ?></h2> 
  911.  
  912. <input name="coupon_code" type="text" class="input-text" id="coupon_code" value="" placeholder="<?php _e('Coupon code', 'evolve'); ?>" /> 
  913. <input type="submit" class="button medium default" name="apply_coupon" value="<?php _e('Apply', 'evolve'); ?>" /> 
  914.  
  915. <?php do_action('woocommerce_cart_coupon'); ?> 
  916.  
  917. </div> 
  918. <?php 
  919. ?> 
  920. </div> 
  921. <?php 
  922.  
  923. add_action('woocommerce_before_cart_totals', 'evolve_woocommerce_before_cart_totals', 20); 
  924.  
  925. function evolve_woocommerce_before_cart_totals($args) { 
  926. global $woocommerce; 
  927. ?> 
  928.  
  929. <form action="<?php echo esc_url(WC()->cart->get_cart_url()); ?>" method="post"> 
  930.  
  931. <?php 
  932.  
  933. add_action('woocommerce_after_cart', 'evolve_woocommerce_after_cart'); 
  934.  
  935. function evolve_woocommerce_after_cart($args) { 
  936. ?> 
  937.  
  938. </form> 
  939.  
  940. <?php 
  941.  
  942. remove_action('woocommerce_cart_collaterals', 'woocommerce_cross_sell_display'); 
  943. add_action('woocommerce_cart_collaterals', 'evolve_woocommerce_cross_sell_display', 5); 
  944.  
  945. function evolve_woocommerce_cross_sell_display() { 
  946. global $product, $woocommerce_loop, $post, $smof_data; 
  947.  
  948. $crosssells = WC()->cart->get_cross_sells(); 
  949.  
  950. if (sizeof($crosssells) == 0) 
  951. return; 
  952.  
  953. $number_of_columns = 4; 
  954.  
  955. woocommerce_cross_sell_display(apply_filters('woocommerce_cross_sells_total', -1), $number_of_columns); 
  956.  
  957. /** end cart hooks */ 
  958.  
  959. /** begin checkout hooks */ 
  960. remove_action('woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10); 
  961. add_action('woocommerce_before_checkout_form', 'evolve_woocommerce_checkout_coupon_form', 10); 
  962.  
  963. function evolve_woocommerce_checkout_coupon_form($args) { 
  964. global $woocommerce; 
  965.  
  966. if (!WC()->cart->coupons_enabled()) 
  967. return; 
  968. ?> 
  969.  
  970. <form class="woocommerce-content-box full-width checkout_coupon" method="post"> 
  971.  
  972. <h2 class="promo-code-heading alignleft"><?php _e('Have A Promotional Code?', 'evolve'); ?></h2> 
  973.  
  974. <div class="coupon-contents alignright"> 
  975. <div class="form-row form-row-first alignleft coupon-input"> 
  976. <input type="text" name="coupon_code" class="input-text" placeholder="<?php _e('Coupon code', 'evolve'); ?>" id="coupon_code" value="" /> 
  977. </div> 
  978.  
  979. <div class="form-row form-row-last alignleft coupon-button"> 
  980. <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'evolve'); ?>" /> 
  981. </div> 
  982.  
  983. <div class="clear"></div> 
  984. </div> 
  985. </form> 
  986. <?php 
  987.  
  988. $evolve_woocommerce_option = get_option('evl_options'); 
  989. $woocommerce_one_page_checkout = isset($evolve_woocommerce_option['evl_woocommerce_one_page_checkout']) ? $evolve_woocommerce_option['evl_woocommerce_one_page_checkout'] : ''; 
  990.  
  991. if ($woocommerce_one_page_checkout != '1') { 
  992. add_action('woocommerce_before_checkout_form', 'evolve_woocommerce_before_checkout_form'); 
  993.  
  994. function evolve_woocommerce_before_checkout_form($args) { 
  995. global $woocommerce; 
  996. ?> 
  997.  
  998. <ul class="woocommerce-side-nav woocommerce-checkout-nav"> 
  999. <li class="active"> 
  1000. <a data-name="col-1" href="#"> 
  1001. <?php _e('Billing Address', 'evolve'); ?> 
  1002. </a> 
  1003. </li> 
  1004. <?php if (WC()->cart->needs_shipping() && !WC()->cart->ship_to_billing_address_only()) : ?> 
  1005. <li> 
  1006. <a data-name="col-2" href="#"> 
  1007. <?php _e('Shipping Address', 'evolve'); ?> 
  1008. </a> 
  1009. </li> 
  1010. <?php 
  1011. elseif (apply_filters('woocommerce_enable_order_notes_field', get_option('woocommerce_enable_order_comments', 'yes') === 'yes')) : 
  1012.  
  1013. if (!WC()->cart->needs_shipping() || WC()->cart->ship_to_billing_address_only()) : 
  1014. ?> 
  1015.  
  1016. <li> 
  1017. <a data-name="col-2" href="#"> 
  1018. <?php _e('Additional Information', 'evolve'); ?> 
  1019. </a> 
  1020. </li> 
  1021. <?php 
  1022. endif; 
  1023. endif; 
  1024. ?> 
  1025.  
  1026. <li> 
  1027. <a data-name="#order_review" href="#"> 
  1028. <?php _e('Review & Payment', 'evolve'); ?> 
  1029. </a> 
  1030. </li> 
  1031. </ul> 
  1032.  
  1033. <div class="woocommerce-content-box evolve-checkout"> 
  1034.  
  1035. <?php 
  1036.  
  1037. if (!$woocommerce_one_page_checkout) { 
  1038. add_action('woocommerce_after_checkout_form', 'evolve_woocommerce_after_checkout_form'); 
  1039.  
  1040. function evolve_woocommerce_after_checkout_form($args) { 
  1041. ?> 
  1042.  
  1043. </div> 
  1044.  
  1045. <?php 
  1046.  
  1047. if ($woocommerce_one_page_checkout) { 
  1048. add_action('woocommerce_checkout_before_customer_details', 'evolve_woocommerce_checkout_before_customer_details'); 
  1049.  
  1050. function evolve_woocommerce_checkout_before_customer_details($args) { 
  1051. global $woocommerce; 
  1052.  
  1053. if (WC()->cart->needs_shipping() && !WC()->cart->ship_to_billing_address_only() || 
  1054. apply_filters('woocommerce_enable_order_notes_field', get_option('woocommerce_enable_order_comments', 'yes') === 'yes') && (!WC()->cart->needs_shipping() || WC()->cart->ship_to_billing_address_only() ) 
  1055. ) { 
  1056. return; 
  1057. } else { 
  1058. ?> 
  1059.  
  1060. <div class="evolve-checkout-no-shipping"> 
  1061.  
  1062. <?php 
  1063.  
  1064. if ($woocommerce_one_page_checkout) { 
  1065. add_action('woocommerce_checkout_after_customer_details', 'evolve_woocommerce_checkout_after_customer_details'); 
  1066.  
  1067. function evolve_woocommerce_checkout_after_customer_details($args) { 
  1068. global $woocommerce; 
  1069.  
  1070. if (WC()->cart->needs_shipping() && !WC()->cart->ship_to_billing_address_only() || 
  1071. apply_filters('woocommerce_enable_order_notes_field', get_option('woocommerce_enable_order_comments', 'yes') === 'yes') && (!WC()->cart->needs_shipping() || WC()->cart->ship_to_billing_address_only() ) 
  1072. ) { 
  1073. ?> 
  1074.  
  1075. <div class="clearboth"></div> 
  1076.  
  1077. <?php } else { ?> 
  1078.  
  1079. <div class="clearboth"></div> 
  1080. </div> 
  1081.  
  1082. <?php } ?> 
  1083.  
  1084. <div class="woocommerce-content-box full-width clearfix"> 
  1085.  
  1086. <?php 
  1087.  
  1088. add_action('woocommerce_checkout_billing', 'evolve_woocommerce_checkout_billing', 20); 
  1089.  
  1090. function evolve_woocommerce_checkout_billing($args) { 
  1091. global $woocommerce; 
  1092.  
  1093. if (WC()->cart->needs_shipping() && !WC()->cart->ship_to_billing_address_only() || 
  1094. apply_filters('woocommerce_enable_order_notes_field', get_option('woocommerce_enable_order_comments', 'yes') === 'yes') && (!WC()->cart->needs_shipping() || WC()->cart->ship_to_billing_address_only() ) 
  1095. ) { 
  1096. $data_name = 'col-2'; 
  1097. } else { 
  1098. $data_name = '#order_review'; 
  1099. $evolve_woocommerce_option = get_option('evl_options'); 
  1100. $woocommerce_one_page_checkout = $evolve_woocommerce_option['evl_woocommerce_one_page_checkout']; 
  1101. if (!$woocommerce_one_page_checkout) { 
  1102. ?> 
  1103.  
  1104. <a data-name="<?php echo $data_name; ?>" href="#" class="button default medium submit t4p-button-default continue-checkout"><?php _e('Continue', 'evolve'); ?></a> 
  1105. <div class="clearboth"></div> 
  1106.  
  1107. <?php 
  1108.  
  1109. add_action('woocommerce_checkout_shipping', 'evolve_woocommerce_checkout_shipping', 20); 
  1110.  
  1111. function evolve_woocommerce_checkout_shipping($args) { 
  1112.  
  1113. $evolve_woocommerce_option = get_option('evl_options'); 
  1114. $woocommerce_one_page_checkout = $evolve_woocommerce_option['evl_woocommerce_one_page_checkout']; 
  1115.  
  1116. if (!$woocommerce_one_page_checkout) { 
  1117. ?> 
  1118.  
  1119. <a data-name="#order_review" href="#" class="button default medium submit t4p-button-default continue-checkout"><?php _e('Continue', 'evolve'); ?></a> 
  1120. <div class="clearboth"></div> 
  1121.  
  1122. <?php 
  1123.  
  1124. add_filter('woocommerce_enable_order_notes_field', 'evolve_enable_order_notes_field'); 
  1125.  
  1126. function evolve_enable_order_notes_field() { 
  1127.  
  1128. $woocommerce_enable_order_notes = evolve_get_option('evl_woocommerce_enable_order_notes', '0'); 
  1129.  
  1130. if (!$woocommerce_enable_order_notes) { 
  1131. return 0; 
  1132.  
  1133. return 1; 
  1134.  
  1135. //function under order hooks 
  1136. remove_action('woocommerce_thankyou', 'woocommerce_order_details_table', 10); 
  1137. add_action('woocommerce_thankyou', 'evolve_woocommerce_view_order', 10); 
  1138. /** end checkout hooks */ 
  1139.  
  1140. /** begin my-account hooks */ 
  1141.  
  1142. add_action('woocommerce_before_customer_login_form', 'evolve_woocommerce_before_customer_login_form'); 
  1143.  
  1144. function evolve_woocommerce_before_customer_login_form() { 
  1145.  
  1146. global $woocommerce; 
  1147.  
  1148. if (get_option('woocommerce_enable_myaccount_registration') !== 'yes') : 
  1149. ?> 
  1150.  
  1151. <div id="customer_login" class="woocommerce-content-box full-width"> 
  1152.  
  1153. <?php 
  1154. endif; 
  1155.  
  1156. add_action('woocommerce_after_customer_login_form', 'evolve_woocommerce_after_customer_login_form'); 
  1157.  
  1158. function evolve_woocommerce_after_customer_login_form() { 
  1159.  
  1160. global $woocommerce; 
  1161.  
  1162. if (get_option('woocommerce_enable_myaccount_registration') !== 'yes') : 
  1163. ?> 
  1164.  
  1165. </div> 
  1166.  
  1167. <?php 
  1168. endif; 
  1169.  
  1170. add_action('woocommerce_account_dashboard', 'evolve_woocommerce_account_dashboard'); 
  1171.  
  1172. function evolve_woocommerce_account_dashboard() { 
  1173.  
  1174. global $woocommerce, $current_user; 
  1175. $woo_acc_msg_1 = evolve_get_option('evl_woo_acc_msg_1', 'Call us - <i class="t4p-icon-phone"></i> 7438 882 764'); 
  1176. $woo_acc_msg_2 = evolve_get_option('evl_woo_acc_msg_2', 'Email us - <i class="t4p-icon-envelope-o"></i> contact@example.com'); 
  1177. ?> 
  1178.  
  1179. <p class="evolve_myaccount_user"> 
  1180. <span class="myaccount_user_container"> 
  1181. <span class="username"> 
  1182. <?php 
  1183. printf( 
  1184. __('Hello, %s', 'evolve'), $current_user->display_name 
  1185. ); 
  1186. ?> 
  1187. </span> 
  1188. <?php if ($woo_acc_msg_1): ?> 
  1189. <span class="msg"> 
  1190. <?php echo $woo_acc_msg_1; ?> 
  1191. </span> 
  1192. <?php 
  1193. endif; 
  1194. if ($woo_acc_msg_2): 
  1195. ?> 
  1196. <span class="msg"> 
  1197. <?php echo $woo_acc_msg_2; ?> 
  1198. </span> 
  1199. <?php endif; ?> 
  1200. <span class="view-cart"> 
  1201. <a class="button default medium submit t4p-button-default" href="<?php echo get_permalink(get_option('woocommerce_cart_page_id')); ?>"><?php _e('View Cart', 'evolve'); ?></a> 
  1202. </span> 
  1203. </span> 
  1204. </p> 
  1205. <div class="woocommerce-side-nav"> 
  1206. <ul class="woocommerce-side-nav-ul evolve-myaccount-nav"> 
  1207. <li <?php 
  1208. if (isset($_SESSION['formvalue'])): 
  1209. else: 
  1210. echo 'class="active"'; 
  1211. endif; 
  1212. ?> 
  1213. <a class="dashboard" href="#"> 
  1214. <?php _e('Dashboard', 'evolve'); ?> 
  1215. </a> 
  1216. </li> 
  1217.  
  1218. <li> 
  1219. <a class="downloads" href="#"> 
  1220. <?php _e('View Downloads', 'evolve'); ?> 
  1221. </a> 
  1222. </li> 
  1223.  
  1224. <li> 
  1225. <a class="orders" href="#"> 
  1226. <?php _e('View Orders', 'evolve'); ?> 
  1227. </a> 
  1228. </li> 
  1229.  
  1230. <li <?php 
  1231. if (isset($_SESSION['formvalue'])) { 
  1232. echo 'class="active"'; 
  1233. ?> 
  1234. <a class="address" href="#"> 
  1235. <?php _e('Change Address', 'evolve'); ?> 
  1236. </a> 
  1237. </li> 
  1238.  
  1239. <li> 
  1240. <a class="account" href="#"> 
  1241. <?php _e('Edit Account', 'evolve'); ?> 
  1242. </a> 
  1243. </li> 
  1244.  
  1245. </ul> 
  1246. <ul class="woocommerce-side-nav-ul woocommerce-side-nav-logout"> 
  1247. <li> 
  1248. <a class="logout" href="<?php echo esc_url(wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount'))); ?>"> 
  1249. <?php _e('Logout', 'evolve'); ?> 
  1250. </a> 
  1251. </li> 
  1252. </ul> 
  1253. </div> 
  1254. <div class="woocommerce-content-box evolve-myaccount-data"> 
  1255.  
  1256. <?php 
  1257.  
  1258. add_action('woocommerce_view_dashboard', 'evolve_woocommerce_view_dashboard'); 
  1259.  
  1260. function evolve_woocommerce_view_dashboard($args) { 
  1261. global $woocommerce, $current_user; 
  1262. $woo_acc_msg_1 = evolve_get_option('evl_woo_acc_msg_1', 'Call us - <i class="t4p-icon-phone"></i> 7438 882 764'); 
  1263. $woo_acc_msg_2 = evolve_get_option('evl_woo_acc_msg_2', 'Email us - <i class="t4p-icon-envelope-o"></i> contact@example.com'); 
  1264. ?> 
  1265. <div class="view_dashboard" <?php 
  1266. if (isset($_SESSION['formvalue'])) { 
  1267. echo 'style="display:none"'; 
  1268. ?> > 
  1269. <p> 
  1270. <?php 
  1271. echo sprintf(esc_attr__('Hello %s%s%s (not %2$s? %sSign out%s)', 'evolve'), '<strong>', esc_html($current_user->display_name), '</strong>', '<a href="' . esc_url(wc_get_endpoint_url('customer-logout', '', wc_get_page_permalink('myaccount'))) . '">', '</a>'); 
  1272. ?> 
  1273. </p> 
  1274.  
  1275. <p> 
  1276. <?php 
  1277. echo sprintf(esc_attr__('From your account dashboard you can view your %1$srecent orders%2$s, manage your %3$sshipping and billing addresses%2$s and %4$sedit your password and account details%2$s.', 'evolve'), '<a href="' . esc_url(wc_get_endpoint_url('orders')) . '">', '</a>', '<a href="' . esc_url(wc_get_endpoint_url('edit-address')) . '">', '<a href="' . esc_url(wc_get_endpoint_url('edit-account')) . '">'); 
  1278. ?> 
  1279. </p> 
  1280. </div> 
  1281. <?php 
  1282.  
  1283. add_action('woocommerce_account_orders', 'evolve_woocommerce_before_account_orders'); 
  1284.  
  1285. function evolve_woocommerce_before_account_orders($args) { 
  1286. $order_count = ""; 
  1287. $my_orders_columns = apply_filters('woocommerce_my_account_my_orders_columns', array( 
  1288. 'order-number' => __('Order', 'evolve'),  
  1289. 'order-date' => __('Date', 'evolve'),  
  1290. 'order-status' => __('Status', 'evolve'),  
  1291. 'order-total' => __('Total', 'evolve'),  
  1292. 'order-actions' => ' ',  
  1293. )); 
  1294.  
  1295. $customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array( 
  1296. 'numberposts' => $order_count,  
  1297. 'meta_key' => '_customer_user',  
  1298. 'meta_value' => get_current_user_id(),  
  1299. 'post_type' => wc_get_order_types('view-orders'),  
  1300. 'post_status' => array_keys(wc_get_order_statuses()) 
  1301. ))); 
  1302.  
  1303. if ($customer_orders) : 
  1304. ?> 
  1305.  
  1306. <h2><?php echo apply_filters('woocommerce_my_account_my_orders_title', __('Recent Orders', 'evolve')); ?></h2> 
  1307.  
  1308. <table class="shop_table shop_table_responsive my_account_orders"> 
  1309.  
  1310. <thead> 
  1311. <tr> 
  1312. <?php foreach ($my_orders_columns as $column_id => $column_name) : ?> 
  1313. <th class="<?php echo esc_attr($column_id); ?>"><span class="nobr"><?php echo esc_html($column_name); ?></span></th> 
  1314. <?php endforeach; ?> 
  1315. </tr> 
  1316. </thead> 
  1317.  
  1318. <tbody> 
  1319. <?php 
  1320. foreach ($customer_orders as $customer_order) : 
  1321. $order = wc_get_order($customer_order); 
  1322. $item_count = $order->get_item_count(); 
  1323. ?> 
  1324. <tr class="order"> 
  1325. <?php foreach ($my_orders_columns as $column_id => $column_name) : ?> 
  1326. <td class="<?php echo esc_attr($column_id); ?>" data-title="<?php echo esc_attr($column_name); ?>"> 
  1327. <?php if (has_action('woocommerce_my_account_my_orders_column_' . $column_id)) : ?> 
  1328. <?php do_action('woocommerce_my_account_my_orders_column_' . $column_id, $order); ?> 
  1329.  
  1330. <?php elseif ('order-number' === $column_id) : ?> 
  1331. <a href="<?php echo esc_url($order->get_view_order_url()); ?>"> 
  1332. <?php echo _x('#', 'hash before order number', 'evolve') . $order->get_order_number(); ?> 
  1333. </a> 
  1334.  
  1335. <?php elseif ('order-date' === $column_id) : ?> 
  1336. <?php echo wc_format_datetime( $order->get_date_created() ); ?> 
  1337.  
  1338. <?php elseif ('order-status' === $column_id) : ?> 
  1339. <?php echo wc_get_order_status_name($order->get_status()); ?> 
  1340.  
  1341. <?php elseif ('order-total' === $column_id) : ?> 
  1342. <?php echo sprintf(_n('%s for %s item', '%s for %s items', $item_count, 'evolve'), $order->get_formatted_order_total(), $item_count); ?> 
  1343.  
  1344. <?php elseif ('order-actions' === $column_id) : ?> 
  1345. <?php 
  1346. $actions = array( 
  1347. 'pay' => array( 
  1348. 'url' => $order->get_checkout_payment_url(),  
  1349. 'name' => __('Pay', 'evolve') 
  1350. ),  
  1351. 'view' => array( 
  1352. 'url' => $order->get_view_order_url(),  
  1353. 'name' => __('View', 'evolve') 
  1354. ),  
  1355. 'cancel' => array( 
  1356. 'url' => $order->get_cancel_order_url(wc_get_page_permalink('myaccount')),  
  1357. 'name' => __('Cancel', 'evolve') 
  1358. ); 
  1359.  
  1360. if (!$order->needs_payment()) { 
  1361. unset($actions['pay']); 
  1362.  
  1363. if (!in_array($order->get_status(), apply_filters('woocommerce_valid_order_statuses_for_cancel', array('pending', 'failed'), $order))) { 
  1364. unset($actions['cancel']); 
  1365.  
  1366. if ($actions = apply_filters('woocommerce_my_account_my_orders_actions', $actions, $order)) { 
  1367. foreach ($actions as $key => $action) { 
  1368. echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>'; 
  1369. ?> 
  1370. <?php endif; ?> 
  1371. </td> 
  1372. <?php endforeach; ?> 
  1373. </tr> 
  1374. <?php endforeach; ?> 
  1375. </tbody> 
  1376. </table> 
  1377. <?php else : ?> 
  1378. <div class="woocommerce-Message woocommerce-Message--info woocommerce-info my_account_orders"> 
  1379. <a class="woocommerce-Button button" href="<?php echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop'))); ?>"> 
  1380. <?php _e('Go Shop', 'evolve') ?> 
  1381. </a> 
  1382. <?php _e('No order has been made yet.', 'evolve'); ?> 
  1383. </div> 
  1384. <?php 
  1385. endif; 
  1386.  
  1387. add_action('woocommerce_account_downloads', 'evolve_woocommerce_before_account_downloads'); 
  1388.  
  1389. function evolve_woocommerce_before_account_downloads($args) { 
  1390. if ($downloads = WC()->customer->get_downloadable_products()) : 
  1391.  
  1392. do_action('woocommerce_before_available_downloads'); 
  1393. ?> 
  1394.  
  1395. <h2><?php echo apply_filters('woocommerce_my_account_my_downloads_title', __('Available Downloads', 'evolve')); ?></h2> 
  1396.  
  1397. <ul class="woocommerce-Downloads digital-downloads"> 
  1398. <?php foreach ($downloads as $download) : ?> 
  1399. <li> 
  1400. <?php 
  1401. do_action('woocommerce_available_download_start', $download); 
  1402.  
  1403. if (is_numeric($download['downloads_remaining'])) { 
  1404. $downloads_remaining = $download['downloads_remaining']; 
  1405. echo apply_filters('woocommerce_available_download_count', '<span class="woocommerce-Count count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $downloads_remaining, 'evolve' ), $download['downloads_remaining'] ) . '</span> ', $download); 
  1406.  
  1407. echo apply_filters('woocommerce_available_download_link', '<a href="' . esc_url($download['download_url']) . '">' . $download['download_name'] . '</a>', $download); 
  1408.  
  1409. do_action('woocommerce_available_download_end', $download); 
  1410. ?> 
  1411. </li> 
  1412. <?php endforeach; ?> 
  1413. </ul> 
  1414.  
  1415. <?php 
  1416. do_action('woocommerce_after_available_downloads'); 
  1417. else : 
  1418. ?> 
  1419. <div class="woocommerce-Message woocommerce-Message--info woocommerce-info digital-downloads"> 
  1420. <a class="woocommerce-Button button" href="<?php echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop'))); ?>"> 
  1421. <?php esc_html_e('Go Shop', 'evolve') ?> 
  1422. </a> 
  1423. <?php esc_html_e('No downloads available yet.', 'evolve'); ?> 
  1424. </div> 
  1425. <?php 
  1426. endif; 
  1427.  
  1428. add_action('woocommerce_account_address', 'evolve_woocommerce_before_my_account'); 
  1429.  
  1430. function evolve_woocommerce_before_my_account($args) { 
  1431. $address_session = ''; 
  1432. if (isset($_SESSION['formvalue'])) { 
  1433. $address_session = 'style="display:block"'; 
  1434. ?> 
  1435. <div class="myaccount_address" id="change_address" <?php echo $address_session; ?>> 
  1436. <h2 class="edit_address_heading" <?php echo $address_session; ?>><?php echo apply_filters('woocommerce_my_account_edit_address_title', 'My Address'); ?></h2> 
  1437. <?php 
  1438. $customer_id = get_current_user_id(); 
  1439.  
  1440. if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) { 
  1441. $get_addresses = apply_filters('woocommerce_my_account_get_addresses', array( 
  1442. 'billing' => __('Billing Address', 'evolve'),  
  1443. 'shipping' => __('Shipping Address', 'evolve') 
  1444. ), $customer_id); 
  1445. } else { 
  1446. $get_addresses = apply_filters('woocommerce_my_account_get_addresses', array( 
  1447. 'billing' => __('Billing Address', 'evolve') 
  1448. ), $customer_id); 
  1449.  
  1450. $oldcol = 1; 
  1451. $col = 1; 
  1452. ?> 
  1453.  
  1454. <p> 
  1455. <?php echo apply_filters('woocommerce_my_account_my_address_description', __('The following addresses will be used on the checkout page by default.', 'evolve')); ?> 
  1456. </p> 
  1457.  
  1458. <?php 
  1459. if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) 
  1460. echo '<div class="u-columns woocommerce-Addresses col2-set">'; 
  1461.  
  1462. foreach ($get_addresses as $name => $title) : 
  1463. ?> 
  1464.  
  1465. <div class="u-column<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> col-<?php echo ( ( $oldcol = $oldcol * -1 ) < 0 ) ? 1 : 2; ?> woocommerce-Address"> 
  1466. <header class="woocommerce-Address-title title"> 
  1467. <h3><?php echo $title; ?></h3> 
  1468. <a href="#" data-name="<?php echo $name; ?>" id="editaddress_<?php echo $name; ?>" class="edit woo_editaddress"><?php _e('Edit', 'evolve'); ?></a> 
  1469. </header> 
  1470. <address> 
  1471. <?php 
  1472. $address = apply_filters('woocommerce_my_account_my_address_formatted_address', array( 
  1473. 'first_name' => get_user_meta($customer_id, $name . '_first_name', true),  
  1474. 'last_name' => get_user_meta($customer_id, $name . '_last_name', true),  
  1475. 'company' => get_user_meta($customer_id, $name . '_company', true),  
  1476. 'address_1' => get_user_meta($customer_id, $name . '_address_1', true),  
  1477. 'address_2' => get_user_meta($customer_id, $name . '_address_2', true),  
  1478. 'city' => get_user_meta($customer_id, $name . '_city', true),  
  1479. 'state' => get_user_meta($customer_id, $name . '_state', true),  
  1480. 'postcode' => get_user_meta($customer_id, $name . '_postcode', true),  
  1481. 'country' => get_user_meta($customer_id, $name . '_country', true) 
  1482. ), $customer_id, $name); 
  1483.  
  1484. $formatted_address = WC()->countries->get_formatted_address($address); 
  1485.  
  1486. if (!$formatted_address) 
  1487. _e('You have not set up this type of address yet.', 'evolve'); 
  1488. else 
  1489. echo $formatted_address; 
  1490. ?> 
  1491. </address> 
  1492. </div> 
  1493.  
  1494. <?php 
  1495. endforeach; 
  1496.  
  1497. if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) 
  1498. echo '<div class="clear"></div></div>'; 
  1499.  
  1500. $load_address = 'billing'; 
  1501. $current_user = wp_get_current_user(); 
  1502. $address = WC()->countries->get_address_fields(get_user_meta(get_current_user_id(), $load_address . '_country', true), $load_address . '_'); 
  1503. // Prepare values 
  1504. foreach ($address as $key => $field) { 
  1505. $value = get_user_meta(get_current_user_id(), $key, true); 
  1506.  
  1507. if (!$value) { 
  1508. switch ($key) { 
  1509. case 'billing_email' : 
  1510. case 'shipping_email' : 
  1511. $value = $current_user->user_email; 
  1512. break; 
  1513. case 'billing_country' : 
  1514. case 'shipping_country' : 
  1515. $value = WC()->countries->get_base_country(); 
  1516. break; 
  1517. case 'billing_state' : 
  1518. case 'shipping_state' : 
  1519. $value = WC()->countries->get_base_state(); 
  1520. break; 
  1521.  
  1522. $address[$key]['value'] = apply_filters('woocommerce_my_account_edit_address_field_value', $value, $key, $load_address); 
  1523.  
  1524. $addressform_session = ''; 
  1525. if (isset($_SESSION['formvalue']) && !empty($field['required']) && isset($_POST[$key])) { 
  1526. $addressform_session = 'style=display:block'; 
  1527. } elseif (isset($_SESSION['formvalue'])) { 
  1528. $addressform_session = 'style=display:none'; 
  1529. ?> 
  1530. <h3 class="editaddress_billing" <?php echo $addressform_session; ?>><?php _e('Billing Address', 'evolve'); ?></h3> 
  1531. <div class="editaddress_billing" <?php echo $addressform_session; ?>> 
  1532. <form method="post"> 
  1533.  
  1534. <?php 
  1535. foreach ($address as $key => $field) : 
  1536.  
  1537. woocommerce_form_field($key, $field, !empty($_POST[$key]) ? wc_clean($_POST[$key]) : $field['value'] ); 
  1538.  
  1539. endforeach; 
  1540. ?> 
  1541.  
  1542. <p> 
  1543. <input type="submit" class="button small default alignright" id="saveaddress" name="save_address" value="<?php _e('Save Address', 'evolve'); ?>" /> 
  1544. <?php wp_nonce_field('woocommerce-edit_address'); ?> 
  1545. <input type="hidden" name="action" value="edit_address" /> 
  1546. <input type="hidden" name="formvalue" value="billing" /> 
  1547. <div class="clearboth"></div> 
  1548. </p> 
  1549.  
  1550. </form> 
  1551. </div> 
  1552.  
  1553. <?php 
  1554. $load_address = 'shipping'; 
  1555. $current_user = wp_get_current_user(); 
  1556. $address = WC()->countries->get_address_fields(get_user_meta(get_current_user_id(), $load_address . '_country', true), $load_address . '_'); 
  1557. // Prepare values 
  1558. foreach ($address as $key => $field) { 
  1559.  
  1560. $value = get_user_meta(get_current_user_id(), $key, true); 
  1561.  
  1562. if (!$value) { 
  1563. switch ($key) { 
  1564. case 'billing_email' : 
  1565. case 'shipping_email' : 
  1566. $value = $current_user->user_email; 
  1567. break; 
  1568. case 'billing_country' : 
  1569. case 'shipping_country' : 
  1570. $value = WC()->countries->get_base_country(); 
  1571. break; 
  1572. case 'billing_state' : 
  1573. case 'shipping_state' : 
  1574. $value = WC()->countries->get_base_state(); 
  1575. break; 
  1576.  
  1577. $address[$key]['value'] = apply_filters('woocommerce_my_account_edit_address_field_value', $value, $key, $load_address); 
  1578.  
  1579. $addressform_session = ''; 
  1580. if (isset($_SESSION['formvalue']) && !empty($field['required']) && isset($_POST[$key])) { 
  1581. $addressform_session = 'style=display:block'; 
  1582. } elseif (isset($_SESSION['formvalue'])) { 
  1583. $addressform_session = 'style=display:none'; 
  1584. ?> 
  1585. <h3 class="editaddress_shipping" <?php echo $addressform_session; ?>><?php _e('Shipping Address', 'evolve'); ?></h3> 
  1586. <div class="editaddress_shipping" <?php echo $addressform_session; ?>> 
  1587. <form method="post"> 
  1588.  
  1589. <?php 
  1590. foreach ($address as $key => $field) : 
  1591.  
  1592. woocommerce_form_field($key, $field, !empty($_POST[$key]) ? wc_clean($_POST[$key]) : $field['value'] ); 
  1593.  
  1594. endforeach; 
  1595. ?> 
  1596.  
  1597. <p> 
  1598. <input type="submit" class="button small default alignright" id="saveaddress" name="save_address" value="<?php _e('Save Address', 'evolve'); ?>" /> 
  1599. <?php wp_nonce_field('woocommerce-edit_address'); ?> 
  1600. <input type="hidden" name="action" value="edit_address" /> 
  1601. <input type="hidden" name="formvalue" value="shipping" /> 
  1602. <div class="clearboth"></div> 
  1603. </p> 
  1604.  
  1605. </form> 
  1606. </div> 
  1607. </div> 
  1608. <?php 
  1609. unset($_SESSION['formvalue']); 
  1610.  
  1611. class evolve_WC_Form_Handler extends WC_Form_Handler { 
  1612.  
  1613. public static function init() { 
  1614. remove_action('template_redirect', array('WC_Form_Handler', 'save_address')); 
  1615. add_action('template_redirect', array(__CLASS__, 'evolve_save_address')); 
  1616.  
  1617. public static function evolve_save_address() { 
  1618. global $wp; 
  1619.  
  1620. $formvalue = ''; 
  1621. if ( isset($_POST['formvalue']) ) { 
  1622. $formvalue = $_POST['formvalue']; 
  1623. $_SESSION['formvalue'] = $_POST['formvalue']; 
  1624.  
  1625. if( isset($_POST['_wp_http_referer']) && strpos($_POST['_wp_http_referer'], '/shipping' ) !== false ) { 
  1626. $formvalue = 'shipping'; 
  1627. $_SESSION['formvalue'] = 'shipping'; 
  1628. } elseif ( isset($_POST['_wp_http_referer']) && strpos($_POST['_wp_http_referer'], '/billing' ) !== false ) { 
  1629. $formvalue = 'billing'; 
  1630. $_SESSION['formvalue'] = 'billing'; 
  1631.  
  1632. if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) { 
  1633. return; 
  1634.  
  1635. if (empty($_POST['action']) || 'edit_address' !== $_POST['action'] || empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-edit_address')) { 
  1636. return; 
  1637.  
  1638. $user_id = get_current_user_id(); 
  1639.  
  1640. if ($user_id <= 0) { 
  1641. return; 
  1642.  
  1643. $load_address = ( $formvalue == 'shipping' ) ? 'shipping' : 'billing'; 
  1644.  
  1645. $address = WC()->countries->get_address_fields(esc_attr($_POST[$load_address . '_country']), $load_address . '_'); 
  1646.  
  1647. foreach ($address as $key => $field) { 
  1648. if (!isset($field['type'])) { 
  1649. $field['type'] = 'text'; 
  1650.  
  1651. // Get Value. 
  1652. switch ($field['type']) { 
  1653. case 'checkbox' : 
  1654. $_POST[$key] = isset($_POST[$key]) ? 1 : 0; 
  1655. break; 
  1656. default : 
  1657. $_POST[$key] = isset($_POST[$key]) ? wc_clean($_POST[$key]) : ''; 
  1658. break; 
  1659.  
  1660. // Hook to allow modification of value. 
  1661. $_POST[$key] = apply_filters('woocommerce_process_myaccount_field_' . $key, $_POST[$key]); 
  1662.  
  1663. // Validation: Required fields. 
  1664. if (!empty($field['required']) && empty($_POST[$key])) { 
  1665. wc_add_notice($field['label'] . ' ' . __('is a required field.', 'evolve'), 'error'); 
  1666.  
  1667. if (!empty($_POST[$key])) { 
  1668.  
  1669. // Validation rules 
  1670. if (!empty($field['validate']) && is_array($field['validate'])) { 
  1671. foreach ($field['validate'] as $rule) { 
  1672. switch ($rule) { 
  1673. case 'postcode' : 
  1674. $_POST[$key] = strtoupper(str_replace(' ', '', $_POST[$key])); 
  1675.  
  1676. if (!WC_Validation::is_postcode($_POST[$key], $_POST[$load_address . '_country'])) { 
  1677. wc_add_notice(__('Please enter a valid postcode/ZIP.', 'evolve'), 'error'); 
  1678. } else { 
  1679. $_POST[$key] = wc_format_postcode($_POST[$key], $_POST[$load_address . '_country']); 
  1680. break; 
  1681. case 'phone' : 
  1682. $_POST[$key] = wc_format_phone_number($_POST[$key]); 
  1683.  
  1684. if (!WC_Validation::is_phone($_POST[$key])) { 
  1685. wc_add_notice('<strong>' . $field['label'] . '</strong> ' . __('is not a valid phone number.', 'evolve'), 'error'); 
  1686. break; 
  1687. case 'email' : 
  1688. $_POST[$key] = strtolower($_POST[$key]); 
  1689.  
  1690. if (!is_email($_POST[$key])) { 
  1691. wc_add_notice('<strong>' . $field['label'] . '</strong> ' . __('is not a valid email address.', 'evolve'), 'error'); 
  1692. break; 
  1693.  
  1694. if (wc_notice_count('error') == 0) { 
  1695.  
  1696. foreach ($address as $key => $field) { 
  1697. update_user_meta($user_id, $key, $_POST[$key]); 
  1698.  
  1699. wc_add_notice(__('Address changed successfully.', 'evolve')); 
  1700.  
  1701. do_action('woocommerce_customer_save_address', $user_id, $load_address); 
  1702.  
  1703. wp_safe_redirect(wc_get_page_permalink('myaccount')); 
  1704. exit; 
  1705.  
  1706.  
  1707. evolve_WC_Form_Handler::init(); 
  1708.  
  1709. add_action('woocommerce_account_editaccount', 'evolve_woocommerce_after_my_account'); 
  1710.  
  1711. function evolve_woocommerce_after_my_account($args) { 
  1712. global $woocommerce, $wp; 
  1713.  
  1714. $user = wp_get_current_user(); 
  1715. ?> 
  1716.  
  1717. <h2 class="edit-account-heading"><?php _e('Edit Account', 'evolve'); ?></h2> 
  1718.  
  1719. <form class="edit-account-form" action="" method="post"> 
  1720. <p class="form-row form-row-first"> 
  1721. <label for="account_first_name"><?php _e('First name', 'evolve'); ?> <span class="required">*</span></label> 
  1722. <input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php esc_attr($user->first_name); ?>" /> 
  1723. </p> 
  1724. <p class="form-row form-row-last"> 
  1725. <label for="account_last_name"><?php _e('Last name', 'evolve'); ?> <span class="required">*</span></label> 
  1726. <input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php esc_attr($user->last_name); ?>" /> 
  1727. </p> 
  1728. <p class="form-row form-row-wide"> 
  1729. <label for="account_email"><?php _e('Email address', 'evolve'); ?> <span class="required">*</span></label> 
  1730. <input type="email" class="input-text" name="account_email" id="account_email" value="<?php esc_attr($user->user_email); ?>" /> 
  1731. </p> 
  1732. <fieldset> 
  1733. <legend><?php _e('Password Change', 'evolve'); ?></legend> 
  1734.  
  1735. <p class="form-row form-row-wide"> 
  1736. <label for="password_current"><?php _e('Current Password (leave blank to leave unchanged)', 'evolve'); ?></label> 
  1737. <input type="password" class="input-text" name="password_current" id="password_current" /> 
  1738. </p> 
  1739. <p class="form-row form-row-wide"> 
  1740. <label for="password_1"><?php _e('New Password (leave blank to leave unchanged)', 'evolve'); ?></label> 
  1741. <input type="password" class="input-text" name="password_1" id="password_1" /> 
  1742. </p> 
  1743. <p class="form-row form-row-wide"> 
  1744. <label for="password_2"><?php _e('Confirm New Password', 'evolve'); ?></label> 
  1745. <input type="password" class="input-text" name="password_2" id="password_2" /> 
  1746. </p> 
  1747. </fieldset> 
  1748. <div class="clear"></div> 
  1749.  
  1750. <p><input type="submit" class="button small default alignright" name="save_account_details" value="<?php _e('Save changes', 'evolve'); ?>" /></p> 
  1751.  
  1752. <?php wp_nonce_field('save_account_details'); ?> 
  1753. <input type="hidden" name="action" value="save_account_details" /> 
  1754. <div class="clearboth"></div> 
  1755. </form> 
  1756.  
  1757. </div> 
  1758.  
  1759. <?php 
  1760.  
  1761. /** end my-account hooks */ 
  1762.  
  1763. /** begin order hooks */ 
  1764. remove_action('woocommerce_view_order', 'woocommerce_order_details_table', 10); 
  1765. add_action('woocommerce_view_order', 'evolve_woocommerce_view_order', 10); 
  1766.  
  1767. function evolve_woocommerce_view_order($order_id) { 
  1768. global $woocommerce; 
  1769.  
  1770. $order = wc_get_order( $order_id ); 
  1771. $order_item_product = new WC_Order_Item_Product(); 
  1772. ?> 
  1773. <div class="evolve-order-details woocommerce-content-box full-width"> 
  1774. <h2><?php _e('Order Details', 'evolve'); ?></h2> 
  1775. <table class="shop_table order_details"> 
  1776. <thead> 
  1777. <tr> 
  1778. <th class="product-name"><?php _e('Product', 'evolve'); ?></th> 
  1779. <th class="product-quantity"><?php _e('Quantity', 'evolve'); ?></th> 
  1780. <th class="product-total"><?php _e('Total', 'evolve'); ?></th> 
  1781. </tr> 
  1782. </thead> 
  1783. <tfoot> 
  1784. <?php 
  1785. if ($totals = $order->get_order_item_totals()) 
  1786. foreach ($totals as $total) : 
  1787. ?> 
  1788. <tr> 
  1789. <td class="filler-td"> </td> 
  1790. <th scope="row"><?php echo $total['label']; ?></th> 
  1791. <td class="product-total"><?php echo $total['value']; ?></td> 
  1792. </tr> 
  1793. <?php 
  1794. endforeach; 
  1795. ?> 
  1796. </tfoot> 
  1797. <tbody> 
  1798. <?php 
  1799. if (sizeof($order->get_items()) > 0) { 
  1800.  
  1801. foreach ($order->get_items() as $item) { 
  1802. $_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item); 
  1803. $product = apply_filters( 'woocommerce_order_item_product', $item->get_product(), $item ); 
  1804. ?> 
  1805. <tr class="<?php echo esc_attr(apply_filters('woocommerce_order_item_class', 'order_item', $item, $order)); ?>"> 
  1806. <td class="product-name"> 
  1807. <span class="product-thumbnail"> 
  1808. <?php 
  1809. $cart_item = ''; 
  1810. $cart_item_key = ''; 
  1811. $thumbnail = apply_filters('woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key); 
  1812.  
  1813. if (!$_product->is_visible()) 
  1814. echo $thumbnail; 
  1815. else 
  1816. printf('<a href="%s">%s</a>', $_product->get_permalink(), $thumbnail); 
  1817. ?> 
  1818. </span> 
  1819. <div class="product-info"> 
  1820. <?php 
  1821. if ($_product && !$_product->is_visible()) 
  1822. echo apply_filters('woocommerce_order_item_name', $item['name'], $item); 
  1823. else 
  1824. echo apply_filters('woocommerce_order_item_name', sprintf('<a href="%s">%s</a>', get_permalink($item['product_id']), $item['name']), $item); 
  1825.  
  1826. wc_display_item_meta($item); 
  1827.  
  1828. if ($_product && $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted()) { 
  1829.  
  1830. $download_files = $order_item_product->get_item_downloads(); 
  1831. $i = 0; 
  1832. $links = array(); 
  1833.  
  1834. foreach ($download_files as $download_id => $file) { 
  1835. $i++; 
  1836.  
  1837. $links[] = '<small><a href="' . esc_url($file['download_url']) . '">' . sprintf(__('Download file%s', 'evolve'), ( count($download_files) > 1 ? ' ' . $i . ': ' : ': ')) . esc_html($file['name']) . '</a></small>'; 
  1838.  
  1839. echo '<br/>' . implode('<br/>', $links); 
  1840. ?> 
  1841. </div> 
  1842. </td> 
  1843. <td class="product-quantity"> 
  1844. <?php echo apply_filters('woocommerce_order_item_quantity_html', $item['qty'], $item); ?> 
  1845. </td> 
  1846. <td class="product-total"> 
  1847. <?php echo $order->get_formatted_line_subtotal($item); ?> 
  1848. </td> 
  1849. </tr> 
  1850. <?php 
  1851. $show_purchase_note = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) ); 
  1852. $purchase_note = $product ? $product->get_purchase_note() : ''; 
  1853. if ( $show_purchase_note && $purchase_note ) { 
  1854. ?> 
  1855. <tr class="product-purchase-note"> 
  1856. <td colspan="3"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td> 
  1857. </tr> 
  1858. <?php 
  1859.  
  1860.  
  1861. do_action('woocommerce_order_items_table', $order); 
  1862. ?> 
  1863. </tbody> 
  1864. </table> 
  1865.  
  1866. <?php do_action('woocommerce_order_details_after_order_table', $order); ?> 
  1867. </div> 
  1868.  
  1869. <div class="evolve-customer-details woocommerce-content-box full-width"> 
  1870. <header> 
  1871. <h2><?php _e('Customer details', 'evolve'); ?></h2> 
  1872. </header> 
  1873. <dl class="customer_details"> 
  1874. <?php 
  1875. if ($order->get_customer_note()) 
  1876. echo '<dt>' . __('Note:', 'evolve') . '</dt> <dd>' . $order->get_customer_note() . '</dd>'; 
  1877. if ($order->get_billing_email()) 
  1878. echo '<dt>' . __('Email:', 'evolve') . '</dt> <dd>' . $order->get_billing_email() . '</dd>'; 
  1879. if ($order->get_billing_phone()) 
  1880. echo '<dt>' . __('Telephone:', 'evolve') . '</dt> <dd>' . $order->get_billing_phone() . '</dd>'; 
  1881.  
  1882. // Additional customer details hook 
  1883. do_action('woocommerce_order_details_after_customer_details', $order); 
  1884. ?> 
  1885. </dl> 
  1886.  
  1887. <?php if (get_option('woocommerce_ship_to_billing_address_only') === 'no' && get_option('woocommerce_calc_shipping') !== 'no') : ?> 
  1888.  
  1889. <div class="col2-set addresses"> 
  1890.  
  1891. <div class="col-1"> 
  1892.  
  1893. <?php endif; ?> 
  1894.  
  1895. <header class="title"> 
  1896. <h3><?php _e('Billing Address', 'evolve'); ?></h3> 
  1897. </header> 
  1898. <address><p> 
  1899. <?php 
  1900. if (!$order->get_formatted_billing_address()) 
  1901. _e('N/A', 'evolve'); 
  1902. else 
  1903. echo $order->get_formatted_billing_address(); 
  1904. ?> 
  1905. </p></address> 
  1906.  
  1907. <?php if (get_option('woocommerce_ship_to_billing_address_only') === 'no' && get_option('woocommerce_calc_shipping') !== 'no') : ?> 
  1908.  
  1909. </div><!-- /.col-1 --> 
  1910.  
  1911. <div class="col-2"> 
  1912.  
  1913. <header class="title"> 
  1914. <h3><?php _e('Shipping Address', 'evolve'); ?></h3> 
  1915. </header> 
  1916. <address><p> 
  1917. <?php 
  1918. if (!$order->get_formatted_shipping_address()) 
  1919. _e('N/A', 'evolve'); 
  1920. else 
  1921. echo $order->get_formatted_shipping_address(); 
  1922. ?> 
  1923. </p></address> 
  1924.  
  1925. </div><!-- /.col-2 --> 
  1926.  
  1927. </div><!-- /.col2-set --> 
  1928.  
  1929. <?php endif; ?> 
  1930.  
  1931. <div class="clear"></div> 
  1932.  
  1933. </div> 
  1934.  
  1935. <?php 
  1936.  
  1937. /** end order hooks */ 
.