/wpsc-components/theme-engine-v1/templates/functions/wpsc-user_log_functions.php

  1. <?php 
  2.  
  3. /** 
  4. * WP eCommerce User Account class 
  5. * 
  6. * This class is responsible for theming the User Account page. 
  7. * 
  8. * @package wp-e-commerce 
  9. * @since 3.8 
  10. */ 
  11. global $wpdb, $user_ID, $wpsc_purchlog_statuses, $separator; 
  12.  
  13. if ( get_option( 'permalink_structure' ) != '' ) 
  14. $separator = "?"; 
  15. else 
  16. $separator = "&"; 
  17.  
  18.  
  19. /** 
  20. * wpsc_display_form_fields() 
  21. * 
  22. * This function displays each of the form fields. 
  23. * 
  24. */ 
  25. function wpsc_display_form_fields() { 
  26.  
  27. do_action( 'wpsc_start_display_user_log_form_fields' ); 
  28.  
  29. $wpsc_checkout = wpsc_core_get_checkout(); 
  30.  
  31. $i = 0; 
  32. while ( wpsc_have_checkout_items() ) { 
  33. wpsc_the_checkout_item(); 
  34.  
  35. if ( wpsc_checkout_form_is_header() ) { 
  36. $i ++; 
  37.  
  38. // display headers for form fields 
  39. ?> 
  40.  
  41. <?php if ( $i > 1 ) {?> 
  42. </table> 
  43. <table> 
  44. <?php } ?> 
  45.  
  46. <tr class="checkout-heading-row <?php echo esc_attr( wpsc_the_checkout_item_error_class( false ) );?>"> 
  47. <td <?php wpsc_the_checkout_details_class(); ?> colspan='2'> 
  48. <h4><?php echo esc_html( wpsc_checkout_form_name() );?></h4> 
  49. </td> 
  50. </tr> 
  51. <?php if ( wpsc_is_shipping_details() ) {?> 
  52. <tr class='same_as_shipping_row'> 
  53. <td colspan='2'> 
  54. <?php 
  55. $checked = ''; 
  56. $shipping_same_as_billing = wpsc_get_customer_meta( 'shippingSameBilling' ); 
  57. if ( $shipping_same_as_billing ) { 
  58. $checked = 'checked="checked"'; 
  59. ?> 
  60. <label for='shippingSameBilling'> 
  61. <input type='checkbox' 
  62. value='true' 
  63. data-wpsc-meta-key="shippingSameBilling" 
  64. class="wpsc-visitor-meta" 
  65. name='shippingSameBilling' 
  66. id='shippingSameBilling' <?php echo $checked; ?> /> 
  67. <?php _e( 'Same as billing address:', 'wpsc' ); ?> 
  68. </label> 
  69. <br> 
  70. <span id="shippingsameasbillingmessage"><?php _e('Your orders will be shipped to the billing address', 'wpsc'); ?></span> 
  71. </td> 
  72. </tr> 
  73. <?php } 
  74.  
  75. // Not a header so start display form fields 
  76. } elseif ( $wpsc_checkout->checkout_item->unique_name == 'billingemail' ) { 
  77. ?> 
  78. <?php 
  79.  
  80. $email_markup = "<div class='wpsc_email_address'> 
  81. <p class='" . wpsc_checkout_form_element_id() . "'> 
  82. <label class='wpsc_email_address' for='" . wpsc_checkout_form_element_id() . "'> 
  83. " . __( 'Enter your email address', 'wpsc' ) . " 
  84. </label> 
  85. <p class='wpsc_email_address_p'> 
  86. <img src='https://secure.gravatar.com/avatar/empty?s=60&d=mm' id='wpsc_checkout_gravatar' /> 
  87. " . wpsc_checkout_form_field(); 
  88.  
  89. if ( wpsc_the_checkout_item_error() != '' ) 
  90. $email_markup .= "<p class='validation-error'>" . wpsc_the_checkout_item_error() . "</p>"; 
  91. $email_markup .= "</div>"; 
  92. } else { 
  93. ?> 
  94. <tr> 
  95. <td class='<?php echo wpsc_checkout_form_element_id(); ?>'> 
  96. <label 
  97. for='<?php echo esc_attr( wpsc_checkout_form_element_id() ); ?>'> 
  98. <?php echo wpsc_checkout_form_name();?> 
  99. </label> 
  100. </td> 
  101. <td> 
  102. <?php echo wpsc_checkout_form_field();?> 
  103. <?php if ( wpsc_the_checkout_item_error() != '' ) { ?> 
  104. <p class='validation-error'><?php echo wpsc_the_checkout_item_error(); ?></p> 
  105. <?php } ?> 
  106. </td> 
  107. </tr> 
  108. <?php }//endif; ?> 
  109. <?php } // end while ?> 
  110. <?php 
  111.  
  112. function wpsc_has_downloads() { 
  113. global $wpdb, $user_ID, $files, $links, $products; 
  114.  
  115. $purchases = $wpdb->get_results( "SELECT `id`, `processed` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE user_ID = " . (int) $user_ID . "" ); 
  116. $rowcount = count( $purchases ); 
  117.  
  118. if ( $rowcount >= 1 ) { 
  119. $perchidstr = "("; 
  120. $perchids = array(); 
  121. foreach ( (array) $purchases as $purchase ) { 
  122. $is_transaction = wpsc_check_purchase_processed( $purchase->processed ); 
  123. if( $is_transaction ) { 
  124. $perchids[] = $purchase->id; 
  125. if(!empty($perchids)) { 
  126. $perchidstr .= implode( ', ', $perchids ); 
  127. $perchidstr .= ")"; 
  128. $sql = "SELECT * FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "` WHERE `purchid` IN " . $perchidstr . " AND `active` IN ('1') ORDER BY `datetime` DESC"; 
  129. $products = $wpdb->get_results( $sql, ARRAY_A ); 
  130. $products = apply_filters( 'wpsc_has_downloads_products', $products ); 
  131.  
  132. foreach ( (array)$products as $key => $product ) { 
  133. if( empty( $product['uniqueid'] ) ) { // if the uniqueid is not equal to null, its "valid", regardless of what it is 
  134. $links[] = home_url( '/?downloadid=' . $product['id'] ); 
  135. } else { 
  136. $links[] = home_url( '/?downloadid=' . $product['uniqueid'] ); 
  137. $sql = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE id = %d", $product['fileid'] ); 
  138. $file = $wpdb->get_results( $sql, ARRAY_A ); 
  139. $files[] = $file[0]; 
  140. if ( count( $files ) > 0 ) { 
  141. return true; 
  142. } else { 
  143. return false; 
  144.  
  145. function wpsc_has_purchases() { 
  146.  
  147. global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $purchase_log, $col_count; 
  148.  
  149. /** 
  150. * this finds the earliest timedit-profile in the shopping cart and sorts out the timestamp system for the month by month display 
  151. */ 
  152.  
  153. $earliest_record_sql = "SELECT MIN(`date`) AS `date` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `date`!=''"; 
  154. $earliest_record = $wpdb->get_results( $earliest_record_sql, ARRAY_A ); 
  155.  
  156. if ( $earliest_record[0]['date'] != null ) { 
  157. $form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `display_log` = '1';"; 
  158. $col_count = 4; //+ count( $form_data ); 
  159. $sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `user_ID` IN ('" . $user_ID . "') AND `processed` IN (3, 4, 5) ORDER BY `date` DESC"; 
  160. $purchase_log = $wpdb->get_results( $sql, ARRAY_A ); 
  161.  
  162. return true; 
  163. } else { 
  164.  
  165. return false; 
  166.  
  167. function wpsc_has_purchases_this_month() { 
  168. global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $purchase_log, $col_count; 
  169.  
  170. $i = 0; 
  171. $subtotal = 0; 
  172.  
  173. if ( $purchase_log != null ) 
  174. return true; 
  175. else 
  176. return false; 
  177.  
  178. /** 
  179. * Displays the Account Page tabs 
  180. * 
  181. * @access public 
  182. * @since 3.8.10 
  183. * 
  184. */ 
  185. function wpsc_user_profile_links( $args = array() ) { 
  186. global $current_tab, $separator; 
  187.  
  188. $defaults = array ( 
  189. 'before_link_list' => '',  
  190. 'after_link_list' => '',  
  191. 'before_link_item' => '',  
  192. 'after_link_item' => '',  
  193. 'link_separator' => '|' 
  194. ); 
  195.  
  196. $args = wp_parse_args( $args, $defaults ); 
  197.  
  198. $profile_tabs = apply_filters( 'wpsc_user_profile_tabs', array( 
  199. 'purchase_history' => __( 'Purchase History', 'wpsc' ),  
  200. 'edit_profile' => __( 'Your Details', 'wpsc' ),  
  201. 'downloads' => __( 'Your Downloads', 'wpsc' ) 
  202. ) ); 
  203.  
  204. echo $args['before_link_list']; 
  205.  
  206. $i = 0; 
  207. $user_account_url = get_option( 'user_account_url' ); 
  208. $links = array(); 
  209. foreach ( $profile_tabs as $tab_id => $tab_title ) : 
  210. $tab_link = $args['before_link_item']; 
  211. $tab_url = add_query_arg( 'tab', $tab_id, $user_account_url ); 
  212. $tab_link = sprintf( 
  213. '<a href="%1$s" class="%2$s">%3$s</a>',  
  214. esc_url( $tab_url ),  
  215. esc_attr( $current_tab == $tab_id ? 'current' : '' ),  
  216. $tab_title 
  217. ); 
  218. $tab_link .= $args['after_link_item']; 
  219. $links[] = $tab_link; 
  220. endforeach; 
  221.  
  222. echo implode( $args['link_separator'], $links ); 
  223.  
  224. echo $args['after_link_list']; 
  225.  
  226. function wpsc_user_purchases() { 
  227. global $wpdb, $user_ID, $wpsc_purchlog_statuses, $gateway_checkout_form_fields, $purchase_log, $col_count, $nzshpcrt_gateways; 
  228.  
  229. $i = 0; 
  230. $subtotal = 0; 
  231.  
  232. do_action( 'wpsc_pre_purchase_logs' ); 
  233.  
  234. foreach ( (array) $purchase_log as $purchase ) { 
  235. $status_state = "expand"; 
  236. $status_style = "display:none;"; 
  237. $alternate = ""; 
  238. $i++; 
  239.  
  240. if ( ($i % 2) != 0 ) 
  241. $alternate = "alt"; 
  242.  
  243. echo "<tr class='$alternate'>\n\r"; 
  244. echo " <td class='status processed'>"; 
  245. echo "<a href=\"#\" onclick=\"return show_details_box('status_box_" . $purchase['id'] . "', 'log_expander_icon_" . $purchase['id'] . "');\">"; 
  246.  
  247. if ( !empty($_GET['id']) && $_GET['id'] == $purchase['id'] ) { 
  248. $status_state = "collapse"; 
  249. $status_style = "style='display: block;'"; 
  250.  
  251. echo "<img class=\"log_expander_icon\" id=\"log_expander_icon_" . $purchase['id'] . "\" src=\"" . WPSC_CORE_IMAGES_URL . "/icon_window_$status_state.gif\" alt=\"\" title=\"\" />"; 
  252.  
  253. echo "<span id='form_group_" . $purchase['id'] . "_text'>" . __( 'Details', 'wpsc' ) . "</span>"; 
  254. echo "</a>"; 
  255. echo " </td>\n\r"; 
  256.  
  257. echo " <td class='date'>"; 
  258. echo date( "jS M Y", $purchase['date'] ); 
  259. echo " </td>\n\r"; 
  260.  
  261. echo " <td class='price'>"; 
  262. $country = get_option( 'country_form_field' ); 
  263. if ( $purchase['shipping_country'] != '' ) { 
  264. $billing_country = $purchase['billing_country']; 
  265. $shipping_country = $purchase['shipping_country']; 
  266. } elseif ( !empty($country)) { 
  267. $country_sql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_SUBMITTED_FORM_DATA . "` WHERE `log_id` = %d AND `form_id` = %d LIMIT 1", $purchase['id'] , get_option( 'country_form_field' ) ); 
  268. $country_data = $wpdb->get_results( $country_sql, ARRAY_A ); 
  269. $billing_country = $country_data[0]['value']; 
  270. $shipping_country = $country_data[0]['value']; 
  271. echo wpsc_currency_display( $purchase['totalprice'], array('display_as_html' => false) ); 
  272. $subtotal += $purchase['totalprice']; 
  273. echo " </td>\n\r"; 
  274.  
  275.  
  276. if ( get_option( 'payment_method' ) == 2 ) { 
  277. echo " <td class='payment_method'>"; 
  278. $gateway_name = ''; 
  279. foreach ( (array)$nzshpcrt_gateways as $gateway ) { 
  280. if ( $purchase['gateway'] != 'testmode' ) { 
  281. if ( $gateway['internalname'] == $purchase['gateway'] ) { 
  282. $gateway_name = $gateway['name']; 
  283. } else { 
  284. $gateway_name = __( "Manual Payment", 'wpsc' ); 
  285. echo $gateway_name; 
  286. echo " </td>\n\r"; 
  287.  
  288. echo "</tr>\n\r"; 
  289. echo "<tr>\n\r"; 
  290. echo " <td colspan='$col_count' class='details'>\n\r"; 
  291. echo " <div id='status_box_" . $purchase['id'] . "' class='order_status' style=\"$status_style\">\n\r"; 
  292. echo " <div>\n\r"; 
  293.  
  294. //order status code lies here 
  295. //check what $purchase['processed'] reflects in the $wpsc_purchlog_statuses array 
  296. $status_name = wpsc_find_purchlog_status_name( $purchase['processed'] ); 
  297. echo " <strong class='form_group'>" . __( 'Order Status', 'wpsc' ) . ":</strong>\n\r"; 
  298. echo $status_name . "<br /><br />"; 
  299.  
  300. do_action( 'wpsc_user_log_after_order_status', $purchase ); 
  301.  
  302. //written by allen 
  303. $usps_id = get_option( 'usps_user_id' ); 
  304. if ( $usps_id != null ) { 
  305. $XML1 = "<TrackFieldRequest USERID=\"$usps_id\"><TrackID ID=\"" . $purchase['track_id'] . "\"></TrackID></TrackFieldRequest>"; 
  306. $ch = curl_init(); 
  307. curl_setopt( $ch, CURLOPT_URL, "http://secure.shippingapis.com/ShippingAPITest.dll?" ); 
  308. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); 
  309. curl_setopt( $ch, CURLOPT_POST, 1 ); 
  310. curl_setopt( $ch, CURLOPT_HEADER, 0 ); 
  311. $postdata = "API=TrackV2&XML=" . $XML1; 
  312. curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata ); 
  313.  
  314. $parser = new xml2array; 
  315. $parsed = $parser->parse( $result ); 
  316. $parsed = $parsed[0]['children'][0]['children']; 
  317. if ( $purchase['track_id'] != null ) { 
  318. echo "<br /><br />"; 
  319. echo " <strong class='form_group'>" . __( 'Shipping Address', 'wpsc' ) . "</strong>\n\r"; 
  320. echo "<table>"; 
  321. foreach ( (array)$parsed as $parse ) { 
  322. if ( $parse['name'] == "TRACKSUMMARY" ) 
  323. foreach ( (array)$parse['children'] as $attrs ) { 
  324. if ( $attrs['name'] != "EVENT" ) 
  325. $attrs['name'] = str_replace( "EVENT", "", $attrs['name'] ); 
  326. $bar = ucfirst( strtolower( $attrs['name'] ) ); 
  327. echo "<tr><td>" . $bar . "</td><td>" . $attrs['tagData'] . "</td></tr>"; 
  328. echo "</table>"; 
  329. echo "<br /><br />"; 
  330. //end of written by allen 
  331. //cart contents display starts here; 
  332. echo " <strong class='form_group'>" . __( 'Order Details', 'wpsc' ) . ":</strong>\n\r"; 
  333. $cartsql = $wpdb->prepare( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`= %d", $purchase['id'] ); 
  334. $cart_log = $wpdb->get_results( $cartsql, ARRAY_A ); 
  335. $j = 0; 
  336. // /* 
  337. if ( $cart_log != null ) { 
  338. echo "<table class='logdisplay'>"; 
  339. echo "<tr class='toprow2'>"; 
  340.  
  341. echo " <th class='details_name'>"; 
  342. _e( 'Name', 'wpsc' ); 
  343. echo " </th>"; 
  344.  
  345. echo " <th class='details_quantity'>"; 
  346. _e( 'Quantity', 'wpsc' ); 
  347. echo " </th>"; 
  348.  
  349. echo " <th class='details_price'>"; 
  350. _e( 'Price', 'wpsc' ); 
  351. echo " </th>"; 
  352.  
  353. echo " <th class='details_tax'>"; 
  354. _e( 'GST', 'wpsc' ); 
  355. echo " </th>"; 
  356.  
  357. echo " <th class='details_shipping'>"; 
  358. _e( 'Shipping', 'wpsc' ); 
  359. echo " </th>"; 
  360.  
  361. echo " <th class='details_total'>"; 
  362. _e( 'Total', 'wpsc' ); 
  363. echo " </th>"; 
  364.  
  365. echo "</tr>"; 
  366.  
  367. $gsttotal = false; 
  368. $endtotal = $total_shipping = 0; 
  369. foreach ( (array)$cart_log as $cart_row ) { 
  370. $alternate = ""; 
  371. $j++; 
  372.  
  373. if ( ($j % 2) != 0 ) 
  374. $alternate = "alt"; 
  375.  
  376. $variation_list = ''; 
  377.  
  378. $billing_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : ''; 
  379. $shipping_country = !empty($country_data[0]['value']) ? $country_data[0]['value'] : ''; 
  380.  
  381. $shipping = $cart_row['pnp']; 
  382. $total_shipping += $shipping; 
  383. echo "<tr class='$alternate'>"; 
  384.  
  385. echo " <td class='details_name'>"; 
  386. echo apply_filters( 'the_title', $cart_row['name'] ); 
  387. echo $variation_list; 
  388. echo " </td>"; 
  389.  
  390. echo " <td class='details_quantity'>"; 
  391. echo $cart_row['quantity']; 
  392. echo " </td>"; 
  393.  
  394. echo " <td class='details_price'>"; 
  395. $price = $cart_row['price'] * $cart_row['quantity']; 
  396. echo wpsc_currency_display( $price ); 
  397. echo " </td>"; 
  398.  
  399. echo " <td class='details_tax'>"; 
  400. $gst = $cart_row['tax_charged']; 
  401. if( $gst > 0) 
  402. $gsttotal += $gst; 
  403. echo wpsc_currency_display( $gst , array('display_as_html' => false) ); 
  404. echo " </td>"; 
  405.  
  406. echo " <td class='details_shipping'>"; 
  407. echo wpsc_currency_display( $shipping , array('display_as_html' => false) ); 
  408. echo " </td>"; 
  409.  
  410. echo " <td class='details_total'>"; 
  411. $endtotal += $price; 
  412. echo wpsc_currency_display( ( $shipping + $price ), array('display_as_html' => false) ); 
  413. echo " </td>"; 
  414.  
  415. echo '</tr>'; 
  416. echo "<tr>"; 
  417.  
  418. echo " <td>"; 
  419. echo " </td>"; 
  420.  
  421. echo " <td>"; 
  422. echo " </td>"; 
  423.  
  424. echo " <td>"; 
  425. echo " <td>"; 
  426. echo " </td>"; 
  427. echo " </td>"; 
  428.  
  429. echo " <td class='details_totals_labels'>"; 
  430. echo "<strong>" . __( 'Total Shipping', 'wpsc' ) . ":</strong><br />"; 
  431. echo "<strong>" . __( 'Total Tax', 'wpsc' ) . ":</strong><br />"; 
  432. echo "<strong>" . __( 'Final Total', 'wpsc' ) . ":</strong>"; 
  433. echo " </td>"; 
  434.  
  435. echo " <td class='details_totals_labels'>"; 
  436. $total_shipping += $purchase['base_shipping']; 
  437. $endtotal += $total_shipping; 
  438. $endtotal += $purchase['wpec_taxes_total']; 
  439. echo wpsc_currency_display( $total_shipping, array('display_as_html' => false) ) . "<br />"; 
  440. if ( $gsttotal ) { //if false then must be exclusive.. doesnt seem too reliable needs more testing 
  441. echo wpsc_currency_display( $gsttotal , array('display_as_html' => false) ). "<br />"; 
  442. } else { 
  443. echo wpsc_currency_display( $purchase['wpec_taxes_total'] , array('display_as_html' => false) ). "<br />"; 
  444. echo wpsc_currency_display( $endtotal , array('display_as_html' => false) ); 
  445. echo " </td>"; 
  446.  
  447. echo '</tr>'; 
  448.  
  449. echo "</table>"; 
  450. echo "<br />"; 
  451.  
  452. echo "<strong>" . __( 'Customer Details', 'wpsc' ) . ":</strong>"; 
  453. echo "<table class='customer_details'>"; 
  454.  
  455.  
  456. $usersql = $wpdb->prepare( "SELECT `".WPSC_TABLE_SUBMITTED_FORM_DATA."`.value, `".WPSC_TABLE_CHECKOUT_FORMS."`.* FROM `".WPSC_TABLE_CHECKOUT_FORMS."` LEFT JOIN `".WPSC_TABLE_SUBMITTED_FORM_DATA."` ON `".WPSC_TABLE_CHECKOUT_FORMS."`.id = `".WPSC_TABLE_SUBMITTED_FORM_DATA."`.`form_id` WHERE `".WPSC_TABLE_SUBMITTED_FORM_DATA."`.log_id = %d OR `".WPSC_TABLE_CHECKOUT_FORMS."`.type = 'heading' ORDER BY `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_set`, `".WPSC_TABLE_CHECKOUT_FORMS."`.`checkout_order`", $purchase['id'] ); 
  457. $formfields = $wpdb->get_results($usersql, ARRAY_A); 
  458. if ( !empty($formfields) ) { 
  459.  
  460. foreach ( (array)$formfields as $form_field ) { 
  461. // If its a heading display the Name otherwise continue on 
  462. if( 'heading' == $form_field['type'] ) { 
  463. echo " <tr><td colspan='2'>" . esc_html( $form_field['name'] ) . ":</td></tr>"; 
  464. continue; 
  465.  
  466. switch ($form_field['unique_name']) { 
  467. case 'shippingcountry': 
  468. case 'billingcountry': 
  469. $country = maybe_unserialize($form_field['value']); 
  470. if(is_array($country)) 
  471. $country = $country[0]; 
  472. else 
  473. $country = $form_field['value']; 
  474.  
  475. echo " <tr><td>" . esc_html( $form_field['name'] ) . ":</td><td>" . esc_html( $country ) . "</td></tr>"; 
  476. break; 
  477.  
  478. case 'billingstate': 
  479. case 'shippingstate': 
  480. if(is_numeric($form_field['value'])) 
  481. $state = wpsc_get_state_by_id($form_field['value'], 'name'); 
  482. else 
  483. $state = $form_field['value']; 
  484.  
  485. echo " <tr><td>" . esc_html( $form_field['name'] ) . ":</td><td>" . esc_html( $state ) . "</td></tr>"; 
  486. break; 
  487.  
  488. default: 
  489. echo " <tr><td>" . esc_html( $form_field['name'] ) . ":</td><td>" . esc_html( $form_field['value'] ) . "</td></tr>"; 
  490.  
  491.  
  492. $payment_gateway_names = ''; 
  493. $payment_gateway_names = get_option('payment_gateway_names'); 
  494.  
  495. foreach ( (array)$payment_gateway_names as $gatewayname ) { 
  496. //if the gateway has a custom name 
  497. if (!empty ($gatewayname) ) 
  498. $display_name = $payment_gateway_names[$purchase_log[0]['gateway']]; 
  499. else{ 
  500. //if not fall back on default name 
  501. foreach ( (array)$nzshpcrt_gateways as $gateway ) { 
  502. if ( $gateway['internalname'] == $purchase['gateway']) 
  503. $display_name = $gateway['name']; 
  504.  
  505. echo " <tr><td>" . __( 'Payment Method', 'wpsc' ) . ":</td><td>" . $display_name . "</td></tr>"; 
  506. echo " <tr><td>" . __( 'Purchase #', 'wpsc' ) . ":</td><td>" . $purchase['id'] . "</td></tr>"; 
  507. if ( $purchase['transactid'] != '' ) { 
  508. echo " <tr><td>" . __( 'Transaction Id', 'wpsc' ) . ":</td><td>" . $purchase['transactid'] . "</td></tr>"; 
  509. echo "</table>"; 
  510. echo " </div>\n\r"; 
  511. echo " </div>\n\r"; 
  512. echo " </td>\n\r"; 
  513. echo "</tr>\n\r"; 
  514.  
  515.  
  516. /** 
  517. * Displays the Purchase History template 
  518. * 
  519. * @access private 
  520. * @since 3.8.10 
  521. * 
  522. */ 
  523. function _wpsc_action_purchase_history_section() { 
  524. include( wpsc_get_template_file_path( 'wpsc-account-purchase-history.php' ) ); 
  525. add_action( 'wpsc_user_profile_section_purchase_history', '_wpsc_action_purchase_history_section' ); 
  526.  
  527. /** 
  528. * Displays the Edit Profile template 
  529. * 
  530. * @access private 
  531. * @since 3.8.10 
  532. * 
  533. */ 
  534. function _wpsc_action_edit_profile_section() { 
  535. include( wpsc_get_template_file_path( 'wpsc-account-edit-profile.php' ) ); 
  536. add_action( 'wpsc_user_profile_section_edit_profile', '_wpsc_action_edit_profile_section' ); 
  537.  
  538. /** 
  539. * Displays the Downloads template 
  540. * 
  541. * @access private 
  542. * @since 3.8.10 
  543. * 
  544. */ 
  545. function _wpsc_action_downloads_section() { 
  546. global $files, $products; 
  547.  
  548. $items = array(); 
  549. if ( wpsc_has_downloads() && ! empty( $files ) ) { 
  550. foreach ( $files as $key => $file ) { 
  551. $item = array(); 
  552. if ( $products[$key]['downloads'] > 0 ) { 
  553. $url = add_query_arg( 
  554. 'downloadid',  
  555. $products[$key]['uniqueid'],  
  556. home_url() 
  557. ); 
  558. $item['title'] = sprintf( 
  559. '<a href="%1$s">%2$s</a>',  
  560. esc_url( $url ),  
  561. esc_html( $file['post_title'] ) 
  562. ); 
  563. } else { 
  564. $item['title'] = esc_html( $file['post_title'] ); 
  565.  
  566. $item['downloads'] = $products[$key]['downloads']; 
  567. $item['datetime'] = date( get_option( 'date_format' ), strtotime( $products[$key]['datetime'] ) ); 
  568. $items[] = (object) $item; 
  569.  
  570. include( wpsc_get_template_file_path( 'wpsc-account-downloads.php' ) ); 
  571. add_action( 'wpsc_user_profile_section_downloads', '_wpsc_action_downloads_section' ); 
  572.  
  573. ?> 
.