private function purchase_log_cart_items() { while (wpsc_have_purchaselog_details()) { wpsc_the_purchaselog_item(); ?> <tr> <td><?php echo wpsc_purchaselog_details_name(); ?> </td> <!-- NAME! --> <td><?php echo wpsc_purchaselog_details_SKU(); ?> </td> <!-- SKU! --> <td><?php echo wpsc_purchaselog_details_quantity(); ?> </td> <!-- QUANTITY! --> <td> <?php echo wpsc_currency_display(wpsc_purchaselog_details_price()); do_action('wpsc_additional_sales_amount_info', wpsc_purchaselog_details_id()); ?> </td> <!-- PRICE! --> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_shipping()); ?> </td> <!-- SHIPPING! --> <?php if (wpec_display_product_tax()) { ?> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_tax()); ?> </td> <!-- TAX! --> <?php } ?> <!-- <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_discount()); ?> </td> --> <!-- DISCOUNT! --> <td class="amount"><?php echo wpsc_currency_display(wpsc_purchaselog_details_total()); ?> </td> <!-- TOTAL! --> </tr> <?php } }
function wpsc_display_purchlog_details() { while (wpsc_have_purchaselog_details()) { wpsc_the_purchaselog_item(); ?> <tr> <td><?php echo wpsc_purchaselog_details_name(); ?> </td> <!-- NAME --> <td><?php echo wpsc_purchaselog_details_SKU(); ?> </td> <!-- SKU --> <td><?php echo wpsc_purchaselog_details_quantity(); ?> </td> <!-- QUANTITY--> <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_price(), true); ?> </td> <!-- PRICE --> <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_tax(), true); ?> </td> <!-- TAX --> <?php /* <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_discount(),true); ?></td> <!-- DISCOUNT --> */ ?> <td><?php echo nzshpcrt_currency_display(wpsc_purchaselog_details_total(), true); ?> </td> <!-- TOTAL --> </tr> <?php } }
function wpsc_packing_slip($purchase_id) { global $wpdb, $purchlogitem, $wpsc_cart, $purchlog; if (isset($_REQUEST['purchaselog_id'])) { $purchlogitem = new wpsc_purchaselogs_items((int) $_REQUEST['purchaselog_id']); } $purch_sql = "SELECT * FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `id`='" . $purchase_id . "'"; $purch_data = $wpdb->get_row($purch_sql, ARRAY_A); //echo "<p style='padding-left: 5px;'><strong>".__('Date', 'wpsc')."</strong>:".date("jS M Y", $purch_data['date'])."</p>"; $cartsql = "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid`=" . $purchase_id . ""; $cart_log = $wpdb->get_results($cartsql, ARRAY_A); $j = 0; if ($cart_log != null) { echo "<div class='packing_slip'>\n\r"; echo apply_filters('wpsc_packing_slip_header', '<h2>' . __('Packing Slip', 'wpsc') . "</h2>\n\r"); echo "<strong>" . __('Order', 'wpsc') . " #</strong> " . $purchase_id . "<br /><br />\n\r"; echo "<table>\n\r"; /* $form_sql = "SELECT * FROM `".WPSC_TABLE_SUBMITED_FORM_DATA."` WHERE `log_id` = '".(int)$purchase_id."'"; $input_data = $wpdb->get_results($form_sql,ARRAY_A); */ echo "<tr class='heading'><td colspan='2'><strong>Billing Info</strong></td></tr>"; foreach ((array) $purchlogitem->userinfo as $userinfo) { if ($userinfo['unique_name'] != 'billingcountry') { echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>"; } else { $userinfo['value'] = maybe_unserialize($userinfo['value']); if (is_array($userinfo['value'])) { if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) { echo "<tr><td>State: </td><td>" . $userinfo['value'][1] . "</td></tr>"; } elseif (is_numeric($userinfo['value'][1])) { echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "</td></tr>"; } if (!empty($userinfo['value'][0])) { echo "<tr><td>Country: </td><td>" . $userinfo['value'][0] . "</td></tr>"; } } else { echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>"; } } } echo "<tr class='heading'><td colspan='2'><strong>Shipping Info</strong></td></tr>"; foreach ((array) $purchlogitem->shippinginfo as $userinfo) { if ($userinfo['unique_name'] != 'shippingcountry' && $userinfo['unique_name'] != 'shippingstate') { echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>"; } elseif ($userinfo['unique_name'] == 'shippingcountry') { $userinfo['value'] = maybe_unserialize($userinfo['value']); if (is_array($userinfo['value'])) { if (!empty($userinfo['value'][1]) && !is_numeric($userinfo['value'][1])) { echo "<tr><td>State: </td><td>" . $userinfo['value'][1] . "</td></tr>"; } elseif (is_numeric($userinfo['value'][1])) { echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'][1], 'name') . "</td></tr>"; } if (!empty($userinfo['value'][0])) { echo "<tr><td>Country: </td><td>" . $userinfo['value'][0] . "</td></tr>"; } } else { echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td></tr>"; } } elseif ($userinfo['unique_name'] == 'shippingstate') { if (!empty($userinfo['value']) && !is_numeric($userinfo['value'])) { echo "<tr><td>" . $userinfo['name'] . ": </td><td>" . $userinfo['value'] . "</td</tr>>"; } elseif (is_numeric($userinfo['value'])) { echo "<tr><td>State: </td><td>" . wpsc_get_state_by_id($userinfo['value'], 'name') . "</td></tr>"; } } } // echo('<pre>'.print_r($purchlogitem,true).'</pre>'); /* foreach($input_data as $input_row) { $rekeyed_input[$input_row['form_id']] = $input_row; } if($input_data != null) { $form_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_CHECKOUT_FORMS."` WHERE `active` = '1'",ARRAY_A); // exit('<pre>'.print_r($purch_data, true).'</pre>'); foreach($form_data as $form_field) { switch($form_field['type']) { case 'country': $delivery_region_count = $wpdb->get_var("SELECT COUNT(`regions`.`id`) FROM `".WPSC_TABLE_REGION_TAX."` AS `regions` INNER JOIN `".WPSC_TABLE_CURRENCY_LIST."` AS `country` ON `country`.`id` = `regions`.`country_id` WHERE `country`.`isocode` IN('".$wpdb->escape( $purch_data['billing_country'])."')"); if(is_numeric($purch_data['billing_region']) && ($delivery_region_count > 0)) { echo " <tr><td>".__('State', 'wpsc').":</td><td>".wpsc_get_region($purch_data['billing_region'])."</td></tr>\n\r"; } echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_country($purch_data['billing_country'])."</td></tr>\n\r"; break; case 'delivery_country': echo " <tr><td>".$form_field['name'].":</td><td>".wpsc_get_country($purch_data['shipping_country'])."</td></tr>\n\r"; break; case 'heading': echo " <tr><td colspan='2'><strong>".wp_kses($form_field['name'], array()).":</strong></td></tr>\n\r"; break; default: if($form_field['unique_name'] == 'shippingstate'){ echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".wpsc_get_region($purch_data['shipping_region'])."</td></tr>\n\r"; }else{ echo " <tr><td>".wp_kses($form_field['name'], array() ).":</td><td>".htmlentities(stripslashes($rekeyed_input[$form_field['id']]['value']), ENT_QUOTES,'UTF-8')."</td></tr>\n\r"; } break; } } } else { echo " <tr><td>".__('Name', 'wpsc').":</td><td>".$purch_data['firstname']." ".$purch_data['lastname']."</td></tr>\n\r"; echo " <tr><td>".__('Address', 'wpsc').":</td><td>".$purch_data['address']."</td></tr>\n\r"; echo " <tr><td>".__('Phone', 'wpsc').":</td><td>".$purch_data['phone']."</td></tr>\n\r"; echo " <tr><td>".__('Email', 'wpsc').":</td><td>".$purch_data['email']."</td></tr>\n\r"; } */ if (get_option('payment_method') == 2) { $gateway_name = ''; foreach ($GLOBALS['nzshpcrt_gateways'] as $gateway) { if ($purch_data['gateway'] != 'testmode') { if ($gateway['internalname'] == $purch_data['gateway']) { $gateway_name = $gateway['name']; } } else { $gateway_name = "Manual Payment"; } } } // echo " <tr><td colspan='2'></td></tr>\n\r"; // echo " <tr><td>".__('Payment Method', 'wpsc').":</td><td>".$gateway_name."</td></tr>\n\r"; // //echo " <tr><td>".__('Purchase No.', 'wpsc').":</td><td>".$purch_data['id']."</td></tr>\n\r"; // echo " <tr><td>".__('How The Customer Found Us', 'wpsc').":</td><td>".$purch_data['find_us']."</td></tr>\n\r"; // $engrave_line = explode(",",$purch_data['engravetext']); // echo " <tr><td>".__('Engrave text', 'wpsc')."</td><td></td></tr>\n\r"; // echo " <tr><td>".__('Line 1', 'wpsc').":</td><td>".$engrave_line[0]."</td></tr>\n\r"; // echo " <tr><td>".__('Line 2', 'wpsc').":</td><td>".$engrave_line[1]."</td></tr>\n\r"; // if($purch_data['transactid'] != '') { // echo " <tr><td>".__('Transaction Id', 'wpsc').":</td><td>".$purch_data['transactid']."</td></tr>\n\r"; // } echo "</table>\n\r"; echo "<table class='packing_slip'>"; echo "<tr>"; echo " <th>" . __('Quantity', 'wpsc') . " </th>"; echo " <th>" . __('Name', 'wpsc') . "</th>"; echo " <th>" . __('Price', 'wpsc') . " </th>"; echo " <th>" . __('Shipping', 'wpsc') . " </th>"; echo "<th>" . wpsc_display_tax_label(false) . "</th>"; echo '</tr>'; $endtotal = 0; $all_donations = true; $all_no_shipping = true; $file_link_list = array(); // exit('<pre>'.print_r($cart_log,true).'</pre>'); foreach ($cart_log as $cart_row) { $purchlogitem->the_purch_item(); // exit('<pre>'.print_r, true).'</pre>'); $alternate = ""; $j++; if ($j % 2 != 0) { $alternate = "class='alt'"; } $productsql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`=" . $cart_row['prodid'] . ""; $product_data = $wpdb->get_results($productsql, ARRAY_A); $variation_sql = "SELECT * FROM `" . WPSC_TABLE_CART_ITEM_VARIATIONS . "` WHERE `cart_id`='" . $cart_row['id'] . "'"; $variation_data = $wpdb->get_results($variation_sql, ARRAY_A); $variation_count = count($variation_data); if ($variation_count > 1) { $variation_list = " ("; $i = 0; foreach ($variation_data as $variation) { if ($i > 0) { $variation_list .= ", "; } $value_id = $variation['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list .= $value_data[0]['name']; $i++; } $variation_list .= ")"; } else { if ($variation_count == 1) { $value_id = $variation_data[0]['value_id']; $value_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id`='" . $value_id . "' LIMIT 1", ARRAY_A); $variation_list = " (" . $value_data[0]['name'] . ")"; } else { $variation_list = ''; } } if ($cart_row['donation'] != 1) { $all_donations = false; } if ($cart_row['no_shipping'] != 1) { $shipping = $cart_row['pnp'] * $cart_row['quantity']; $total_shipping += $shipping; $all_no_shipping = false; } else { $shipping = 0; } $price = $cart_row['price'] * $cart_row['quantity']; $gst = $price - $price / (1 + $cart_row['gst'] / 100); if ($gst > 0) { $tax_per_item = $gst / $cart_row['quantity']; } echo "<tr {$alternate}>"; echo " <td>"; echo $cart_row['quantity']; echo " </td>"; echo " <td>"; echo $product_data[0]['name']; echo stripslashes($variation_list); echo " </td>"; echo " <td>"; echo nzshpcrt_currency_display($price, 1); echo " </td>"; echo " <td>"; echo nzshpcrt_currency_display($shipping, 1); echo " </td>"; echo '<td>'; if (wpsc_tax_isincluded()) { echo wpsc_purchaselog_details_tax(); } else { echo nzshpcrt_currency_display($cart_row['tax_charged'], 1); } echo '<td>'; echo '</tr>'; } echo "</table>"; echo '<table class="packing-slip-totals">'; echo '<tr><th>Base Shipping</th><td>' . nzshpcrt_currency_display($purch_data['base_shipping'], 1) . '</td></tr>'; echo '<tr><th>Total Shipping</th><td>' . nzshpcrt_currency_display($purch_data['base_shipping'] + $total_shipping, 1) . '</td></tr>'; echo '<tr><th>Total Price</th><td>' . nzshpcrt_currency_display($purch_data['totalprice'], 1) . '</td></tr>'; echo '</table>'; echo "</div>\n\r"; } else { echo "<br />" . __('This users cart was empty', 'wpsc'); } }
function wpsc_display_purchlog_details() { while (wpsc_have_purchaselog_details()) { wpsc_the_purchaselog_item(); ?> <tr> <td><?php echo wpsc_purchaselog_details_name(); ?> </td> <!-- NAME! --> <td><?php echo wpsc_purchaselog_details_SKU(); ?> </td> <!-- SKU! --> <td><?php echo wpsc_purchaselog_details_quantity(); ?> </td> <!-- QUANTITY! --> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_price()); ?> </td> <!-- PRICE! --> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_shipping()); ?> </td> <!-- SHIPPING! --> <td><?php if (wpec_display_product_tax()) { echo wpsc_currency_display(wpsc_purchaselog_details_tax()); } ?> </td> <!-- TAX! --> <!-- <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_discount()); ?> </td> --> <!-- DISCOUNT! --> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_total()); ?> </td> <!-- TOTAL! --> </tr> <?php } }
function get_packing_slip($purchase_ids, $purchase_id_arr) { global $purchlogitem; if (!empty($purchase_ids) && !empty($purchase_id_arr)) { ?> <style type="text/css"> body { font-family:"Helvetica Neue", Helvetica, Arial, Verdana, sans-serif; } h1 span { font-size:0.75em; } h2 { color: #333; } #wrapper { margin:0 auto; width:95%; page-break-after: always; } #header { } #customer { overflow:hidden; } #customer .shipping, #customer .billing { float: left; width: 50%; } table { border:1px solid #000; border-collapse:collapse; margin-top:1em; width:100%; } th { background-color:#efefef; text-align:center; } th, td { padding:5px; } td { text-align:center; } #cart-items td.amount { text-align:right; } td, tbody th { border-top:1px solid #ccc; } th.column-total { width:90px; } th.column-shipping { width:120px; } th.column-price { width:100px; } </style> <?php if (!class_exists('wpsc_purchaselogs_items')) { require_once WP_PLUGIN_DIR . '/wp-e-commerce/wpsc-includes/purchaselogs.class.php'; } foreach ($purchase_id_arr as $purchase_id_value) { $purchlogitem = new wpsc_purchaselogs_items((int) $purchase_id_value); ?> <div id="wrapper"> <?php echo smart_manager_print_logo(); ?> <div id="header" style="margin-top:-0.8em;"> <h1> <?php echo get_bloginfo('name'); ?> <br /> <span><?php printf(esc_html__('Packing Slip for Order #%s', 'wpsc'), $purchase_id_value); ?> </span> </h1> </div> <div id="customer"> <div class="shipping"> <h2><?php echo esc_html_x('Ship To:', 'packing slip', 'wpsc'); ?> </h2> <strong><?php echo wpsc_display_purchlog_shipping_name(); ?> </strong><br /> <?php echo wpsc_display_purchlog_shipping_address(); ?> <br /> <?php echo wpsc_display_purchlog_shipping_city(); ?> <br /> <?php echo wpsc_display_purchlog_shipping_state_and_postcode(); ?> <br /> <?php echo wpsc_display_purchlog_shipping_country(); ?> <br /> </div> <div class="billing"> <h2><?php echo esc_html_x('Bill To:', 'packing slip', 'wpsc'); ?> </h2> <strong><?php echo wpsc_display_purchlog_buyers_name(); ?> </strong><br /> <?php echo wpsc_display_purchlog_buyers_address(); ?> <br /> <?php echo wpsc_display_purchlog_buyers_city(); ?> <br /> <?php echo wpsc_display_purchlog_buyers_state_and_postcode(); ?> <br /> <?php echo wpsc_display_purchlog_buyers_country(); ?> <br /> </div> </div> <table id="order"> <thead> <tr> <th><?php echo esc_html_x('Order Date', 'packing slip', 'wpsc'); ?> </th> <th><?php echo esc_html_x('Order ID', 'packing slip', 'wpsc'); ?> </th> <th><?php echo esc_html_x('Shipping Method', 'packing slip', 'wpsc'); ?> </th> <th><?php echo esc_html_x('Payment Method', 'packing slip', 'wpsc'); ?> </th> </tr> </thead> <tbody> <tr> <td><?php echo wpsc_purchaselog_details_date(); ?> </td> <td><?php echo wpsc_purchaselog_details_purchnumber(); ?> </td> <td><?php echo wpsc_display_purchlog_shipping_method(); ?> </td> <td><?php echo wpsc_display_purchlog_paymentmethod(); ?> </td> </tr> </tbody> </table> <table id="cart-items" class="widefat" cellspacing="0"> <thead> <tr> <th scope='col' id='title' class='manage-column column-title' style=""><?php _e('Item Name', 'wpsc'); ?> </th> <th scope='col' id='sku' class='manage-column column-sku' style=""><?php _e('SKU', 'wpsc'); ?> </th> <th scope='col' id='quantity' class='manage-column column-quantity' style=""><?php _e('Quantity', 'wpsc'); ?> </th> <th scope='col' id='price' class='manage-column column-price' style=""><?php _e('Price', 'wpsc'); ?> </th> <th scope='col' id='shipping' class='manage-column column-shipping' style=""><?php _e('Item Shipping', 'wpsc'); ?> </th> <th scope='col' id='tax' class='manage-column column-tax' style=""><?php _e('Item Tax', 'wpsc'); ?> </th> <th scope='col' id='total' class='manage-column column-total' style=""><?php _e('Item Total', 'wpsc'); ?> </th> <?php $cols = 5; // this is counted as ( count of th - 2 ) ?> </tr> </thead> <tbody> <?php while (wpsc_have_purchaselog_details()) { wpsc_the_purchaselog_item(); ?> <tr> <td><?php echo wpsc_purchaselog_details_name(); ?> </td> <!-- NAME! --> <td><?php echo wpsc_purchaselog_details_SKU(); ?> </td> <!-- SKU! --> <td><?php echo wpsc_purchaselog_details_quantity(); ?> </td> <!-- QUANTITY! --> <td> <?php echo wpsc_currency_display(wpsc_purchaselog_details_price()); do_action('wpsc_additional_sales_amount_info', wpsc_purchaselog_details_id()); ?> </td> <!-- PRICE! --> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_shipping()); ?> </td> <!-- SHIPPING! --> <?php if (wpec_display_product_tax()) { ?> <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_tax()); ?> </td> <!-- TAX! --> <?php } ?> <!-- <td><?php echo wpsc_currency_display(wpsc_purchaselog_details_discount()); ?> </td> --> <!-- DISCOUNT! --> <td class="amount"><?php echo wpsc_currency_display(wpsc_purchaselog_details_total()); ?> </td> <!-- TOTAL! --> </tr> <?php } ?> <tr class="wpsc_purchaselog_start_totals"> <td colspan="<?php echo $cols; ?> "> <?php if (wpsc_purchlog_has_discount_data()) { ?> <?php esc_html_e('Coupon Code', 'wpsc'); ?> : <?php echo wpsc_display_purchlog_discount_data(); ?> <?php } ?> </td> <th><?php esc_html_e('Discount', 'wpsc'); ?> </th> <td class="amount"><?php echo wpsc_display_purchlog_discount(); ?> </td> </tr> <?php if (!wpec_display_product_tax()) { ?> <tr> <td colspan='<?php echo $cols; ?> '></td> <th><?php esc_html_e('Taxes', 'wpsc'); ?> </th> <td class="amount"><?php echo wpsc_display_purchlog_taxes(); ?> </td> </tr> <?php } ?> <tr> <td colspan='<?php echo $cols; ?> '></td> <th><?php esc_html_e('Shipping', 'wpsc'); ?> </th> <td class="amount"><?php echo wpsc_display_purchlog_shipping(); ?> </td> </tr> <tr> <td colspan='<?php echo $cols; ?> '></td> <th><?php esc_html_e('Total', 'wpsc'); ?> </th> <td class="amount"><?php echo wpsc_display_purchlog_totalprice(); ?> </td> </tr> </tbody> </table> </div> <?php } exit; } }