</span></th> <th class="order-actions"> </th> </tr> </thead> <tbody><?php foreach ($customer_orders as $customer_order) { $order = new WC_Order(); $order->populate($customer_order); $status = get_term_by('slug', $order->status, 'shop_order_status'); $item_count = $order->get_item_count(); ?> <tr class="order"> <td class="order-number"> <a href="<?php echo $order->get_view_order_url(); ?> "> <?php echo $order->get_order_number(); ?> </a> </td> <td class="order-date"> <time datetime="<?php echo date('Y-m-d', strtotime($order->order_date)); ?> " title="<?php echo esc_attr(strtotime($order->order_date)); ?> "><?php
/** * Added support button in order actions. * * @since 1.0.0 * * @param array $actions Order actions. * @param WC_Order $order Order data. * * @return array */ public function orders_actions($actions, $order) { global $woocommerce; // Backwards compatibility for WooCommerce 2.0.x. if (version_compare($woocommerce->version, '2.1', '>=')) { $order_url = $order->get_view_order_url(); } else { $order_url = add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))); } $actions[$this->id] = array('url' => $order_url . '#open-ticket', 'name' => __('Get Help', 'woocommerce-freshdesk')); return $actions; }
/** * Get the order data for the given ID. * * @since 2.5.0 * @param WC_Order $order The order instance * @return array */ protected function get_order_data($order) { $order_post = get_post($order->id); $dp = wc_get_price_decimals(); $order_data = array('id' => $order->id, 'order_number' => $order->get_order_number(), 'created_at' => $this->format_datetime($order_post->post_date_gmt), 'updated_at' => $this->format_datetime($order_post->post_modified_gmt), 'completed_at' => $this->format_datetime($order->completed_date, true), 'status' => $order->get_status(), 'currency' => $order->get_order_currency(), 'total' => wc_format_decimal($order->get_total(), $dp), 'subtotal' => wc_format_decimal($order->get_subtotal(), $dp), 'total_line_items_quantity' => $order->get_item_count(), 'total_tax' => wc_format_decimal($order->get_total_tax(), $dp), 'total_shipping' => wc_format_decimal($order->get_total_shipping(), $dp), 'cart_tax' => wc_format_decimal($order->get_cart_tax(), $dp), 'shipping_tax' => wc_format_decimal($order->get_shipping_tax(), $dp), 'total_discount' => wc_format_decimal($order->get_total_discount(), $dp), 'shipping_methods' => $order->get_shipping_method(), 'payment_details' => array('method_id' => $order->payment_method, 'method_title' => $order->payment_method_title, 'paid' => isset($order->paid_date)), 'billing_address' => array('first_name' => $order->billing_first_name, 'last_name' => $order->billing_last_name, 'company' => $order->billing_company, 'address_1' => $order->billing_address_1, 'address_2' => $order->billing_address_2, 'city' => $order->billing_city, 'state' => $order->billing_state, 'postcode' => $order->billing_postcode, 'country' => $order->billing_country, 'email' => $order->billing_email, 'phone' => $order->billing_phone), 'shipping_address' => array('first_name' => $order->shipping_first_name, 'last_name' => $order->shipping_last_name, 'company' => $order->shipping_company, 'address_1' => $order->shipping_address_1, 'address_2' => $order->shipping_address_2, 'city' => $order->shipping_city, 'state' => $order->shipping_state, 'postcode' => $order->shipping_postcode, 'country' => $order->shipping_country), 'note' => $order->customer_note, 'customer_ip' => $order->customer_ip_address, 'customer_user_agent' => $order->customer_user_agent, 'customer_id' => $order->get_user_id(), 'view_order_url' => $order->get_view_order_url(), 'line_items' => array(), 'shipping_lines' => array(), 'tax_lines' => array(), 'fee_lines' => array(), 'coupon_lines' => array()); // add line items foreach ($order->get_items() as $item_id => $item) { $product = $order->get_product_from_item($item); $product_id = null; $product_sku = null; // Check if the product exists. if (is_object($product)) { $product_id = isset($product->variation_id) ? $product->variation_id : $product->id; $product_sku = $product->get_sku(); } $meta = new WC_Order_Item_Meta($item, $product); $item_meta = array(); foreach ($meta->get_formatted(null) as $meta_key => $formatted_meta) { $item_meta[] = array('key' => $meta_key, 'label' => $formatted_meta['label'], 'value' => $formatted_meta['value']); } $order_data['line_items'][] = array('id' => $item_id, 'subtotal' => wc_format_decimal($order->get_line_subtotal($item, false, false), $dp), 'subtotal_tax' => wc_format_decimal($item['line_subtotal_tax'], $dp), 'total' => wc_format_decimal($order->get_line_total($item, false, false), $dp), 'total_tax' => wc_format_decimal($item['line_tax'], $dp), 'price' => wc_format_decimal($order->get_item_total($item, false, false), $dp), 'quantity' => wc_stock_amount($item['qty']), 'tax_class' => !empty($item['tax_class']) ? $item['tax_class'] : null, 'name' => $item['name'], 'product_id' => $product_id, 'sku' => $product_sku, 'meta' => $item_meta); } // Add shipping. foreach ($order->get_shipping_methods() as $shipping_item_id => $shipping_item) { $order_data['shipping_lines'][] = array('id' => $shipping_item_id, 'method_id' => $shipping_item['method_id'], 'method_title' => $shipping_item['name'], 'total' => wc_format_decimal($shipping_item['cost'], $dp)); } // Add taxes. foreach ($order->get_tax_totals() as $tax_code => $tax) { $order_data['tax_lines'][] = array('id' => $tax->id, 'rate_id' => $tax->rate_id, 'code' => $tax_code, 'title' => $tax->label, 'total' => wc_format_decimal($tax->amount, $dp), 'compound' => (bool) $tax->is_compound); } // Add fees. foreach ($order->get_fees() as $fee_item_id => $fee_item) { $order_data['fee_lines'][] = array('id' => $fee_item_id, 'title' => $fee_item['name'], 'tax_class' => !empty($fee_item['tax_class']) ? $fee_item['tax_class'] : null, 'total' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'total_tax' => wc_format_decimal($order->get_line_tax($fee_item), $dp)); } // Add coupons. foreach ($order->get_items('coupon') as $coupon_item_id => $coupon_item) { $order_data['coupon_lines'][] = array('id' => $coupon_item_id, 'code' => $coupon_item['name'], 'amount' => wc_format_decimal($coupon_item['discount_amount'], $dp)); } $order_data = apply_filters('woocommerce_cli_order_data', $order_data); return $this->flatten_array($order_data); }
function shortcode_altereports_func() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; include_once ABSPATH . WPINC . '/functions.php'; global $wpdb, $woocommerce, $WC_Order, $woo_options, $WC_API_Reports, $WC_Admin_Dashboard, $WC_Admin_Reports, $WC_Admin_Report, $WC_Report_Customers, $WC_Report_Stock, $WC_alterinventory; $results = $wpdb->get_results('SELECT * FROM wp_options WHERE option_id = 1', OBJECT); $out = get_option('<h1 style="color:#F00">alterinventory_error_message</h1>', '<h1 style="color:#F00">Please use your Username and Password to Log In </h1>'); $options = get_option('alterinventory_options'); $user = wp_get_current_user(); if (empty($user->ID)) { echo $out; } if (!is_user_logged_in()) { wp_login_form(); } else { ?> <?php /** * Template for Direct Sells */ if (!defined('ABSPATH')) { exit; } global $wpdb, $Product, $item, $item_meta, $product, $woocommerce, $woo_options, $order_count, $WC_API_Reports, $WC_Admin_Dashboard, $WC_Admin_Reports, $WC_Admin_Report, $WC_Report_Customers, $WC_Report_Stock, $WC_alterinventory; $customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('numberposts' => $order_count, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => 'shop_order', 'post_status' => 'publish', 'posts_per_page' => -1, 'paged' => get_query_var('paged')))); if ($customer_orders) { ?> <div align="right" style="margin-bottom:-60px" > <script type="text/javascript"> function printPage(){ var tableData = '<table border="1">'+document.getElementsByTagName('table')[0].innerHTML+'</table>'; var data = '<button onclick="window.print()"> Print </button>'+tableData; myWindow=window.open('','','width=1000,height=800px'); myWindow.innerWidth = screen.width; myWindow.innerHeight = screen.height; myWindow.screenX = 0; myWindow.screenY = 0; myWindow.document.write(data); myWindow.focus(); }; </script> <br /> <a href="javascript:void(0);" class="button" type="submit" id="printPage" onclick="printPage();">Print</a> | <a href="alter-inventory/" class="button" type="submit" > Aggiorna</a> <br /> </div> <div style="margin-bottom: 40px;" > <?php $form = '<form role="search" method="get" id="searchform" action="' . esc_url(home_url('/')) . '"> <div> <label class="screen-reader-text" for="s">' . __('Cerca Vendite:', 'woocommerce') . '</label> <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __('Vendite..', 'woocommerce') . '" /> <input class="button" type="submit" id="searchsubmit" value="' . esc_attr__('Search', 'woocommerce') . '" /> <input type="hidden" name="post_type" value="product" /> </div> </form>'; echo $form; ?> </div> <h2>VENDITE</h2> <table class="shop_table my_account_orders"> <thead> <tr> <th class="order-number"><span class="nobr"><?php _e('#ID Vendita', 'woocommerce'); ?> </span></th> <th class="order-date"><span class="nobr"><?php _e('Data', 'woocommerce'); ?> </span></th> <th class="order-status"><span class="nobr"><?php _e('Stato', 'woocommerce'); ?> </span></th> <th class="order-total"><span class="nobr"><?php _e('Totale', 'woocommerce'); ?> </span></th> <th class="order-actions"><span class="nobr"><?php _e('Prodotti / Attributi / Totale', 'woocommerce'); ?> </span></th> <th class="order-actions"><span class="nobr"><?php _e('Dettagli', 'woocommerce'); ?> </span></th> <th class="order-actions"><span class="nobr"><?php _e('Annullare', 'woocommerce'); ?> </span></th> </tr> </thead> <style> .hentry img { height: auto; max-width: 35%;} .woocommerce-message { display:none;} </style> <tbody><?php foreach ($customer_orders as $customer_order) { $order = new WC_Order(); $order->populate($customer_order); $status = get_term_by('slug', $order->status, 'shop_order_status'); $item_count = $order->get_item_count(); ?> <tr class="order"> <td class="order-number"> <a href="<?php echo $order->get_view_order_url(); ?> "> <?php echo $order->get_order_number(); ?> </a> </td> <td class="order-date"> <time datetime="<?php echo date('Y-m-d', strtotime($order->order_date)); ?> " title="<?php echo esc_attr(strtotime($order->order_date)); ?> "><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?> </time> </td> <td class="order-status" style="text-align:left; text-transform:uppercase; white-space:nowrap; color:#0C0" > <?php echo ucfirst(__($status->name, 'woocommerce')); ?> </td> <td class="order-total"> <?php echo sprintf(_n('<strong>%s</strong> x <strong>%s Prodotto</strong>', '%s for %s items', $item_count, 'woocommerce'), $order->get_formatted_order_total(), $item_count); ?> </td> <td class="order-actions"> <table class="shop_table order_details"> <thead> <tr> <th class="product-name"><?php _e('Product', 'woocommerce'); ?> </th> <th class="product-total"><?php _e('Total', 'woocommerce'); ?> </th> </tr> </thead> <tfoot> </tfoot> <tbody> <?php if (sizeof($order->get_items()) > 0) { foreach ($order->get_items() as $item) { $_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item); $item_meta = new WC_Order_Item_Meta($item['item_meta'], $_product); ?> <tr class="<?php echo esc_attr(apply_filters('woocommerce_order_item_class', 'order_item', $item, $order)); ?> "> <td style="text-transform:uppercase;"> <?php if ($_product && !$_product->is_visible()) { echo apply_filters('woocommerce_order_item_name', $item['name'], $item); } else { echo apply_filters('woocommerce_order_item_name', sprintf('<a href="%s">%s</a>', get_permalink($item['product_id']), $item['name']), $item); } echo apply_filters('woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf('× %s', $item['qty']) . '</strong>', $item); $item_meta->display(); if ($_product && $_product->exists() && $_product->is_downloadable() && $order->is_download_permitted()) { $download_files = $order->get_item_downloads($item); $i = 0; $links = array(); foreach ($download_files as $download_id => $file) { $i++; $links[] = '<small><a href="' . esc_url($file['download_url']) . '">' . sprintf(__('Download file%s', 'woocommerce'), count($download_files) > 1 ? ' ' . $i . ': ' : ': ') . esc_html($file['name']) . '</a></small>'; } echo '<br/>' . implode('<br/>', $links); } ?> </td> <td class="product-total" style="color:#F00"> <?php echo $order->get_formatted_line_subtotal($item); ?> </td> </tr> <?php } } ?> </tbody> </table> <div class="clear"></div> </td> <td class="order-actions"> <?php $actions = array(); if (in_array($order->status, apply_filters('woocommerce_valid_order_statuses_for_payment', array('Incompleta', 'Fallita'), $order))) { } $actions['view'] = array('url' => $order->get_view_order_url(), 'name' => __('Dettagli', 'woocommerce')); $actions = apply_filters('woocommerce_my_account_my_orders_actions', $actions, $order); if ($actions) { foreach ($actions as $key => $action) { echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>'; } } ?> </td> <td class="order-actions"> <?php $actions = array(); $actions['cancel'] = array('url' => $order->get_cancel_order_url(get_permalink(wc_get_page_id('alter-inventory'))), 'name' => __('Cancel', 'woocommerce')); if ($actions) { foreach ($actions as $key => $action) { echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>'; } } ?> </td> </tr><?php } ?> </tbody> </table> <?php } ?> <?php } }
/** * Test: get_view_order_url */ function test_get_view_order_url() { $object = new WC_Order(); $id = $object->save(); $this->assertEquals('http://example.org?view-order=' . $id, $object->get_view_order_url()); }
function thankyou_page() { global $woocommerce; if (version_compare(WOOCOMMERCE_VERSION, '2.0.20', '>')) { /* WC 2.1 */ global $wp; $order_id = (int) $wp->query_vars['order-received']; } else { $order_id = (int) $_GET['order']; } $order = new WC_Order($order_id); if ($order->status == 'processing' || $order->status == 'completed') { if (version_compare(WOOCOMMERCE_VERSION, '2.0.20', '>')) { /* WC 2.1 */ $url_commande = $order->get_view_order_url(); $montant_commande = wc_price($order->order_total); } else { $url_commande = add_query_arg('order', $order->id, get_permalink(get_option('woocommerce_view_order_page_id'))); $montant_commande = woocommerce_price($order->order_total); } $compte_client = get_post_meta($order->id, '_customer_user', true); printf("<p>" . __("Votre règlement par carte bancaire de %s a bien été finalisé auprès de notre banque"), $montant_commande); if ($compte_client > 0) { printf(__(", <a href=\"%s\">cliquez ici</a> pour consulter votre commande.", "atos") . "</p>", $url_commande); } else { echo ".</p>"; } } elseif ($order->status != 'failed') { if (version_compare(WOOCOMMERCE_VERSION, '2.0.14', '>=')) { /* WC 2.1 */ $payer_url = $order->get_checkout_payment_url(); } else { $payer_url = add_query_arg('order_id', $order->id, add_query_arg('order', $order->order_key, add_query_arg('pay_for_order', 'true', get_permalink(get_option('woocommerce_pay_page_id'))))); } printf("<p>" . __("Échec du règlement par carte bancaire de votre commande, <a href=\"%s\">cliquez ici</a> pour effectuer une nouvelle tentative de paiement.", "atos") . "</p>", $payer_url); /* WC 2.1 */ } }
/** * Show sub-orders on a parent order if available * * @param WC_Order $parent_order * @return void */ function dokan_order_show_suborders($parent_order) { $sub_orders = get_children(array('post_parent' => $parent_order->id, 'post_type' => 'shop_order', 'post_status' => array('wc-pending', 'wc-completed', 'wc-processing', 'wc-on-hold'))); if (!$sub_orders) { return; } ?> <header> <h2><?php _e('Sub Orders', 'dokan'); ?> </h2> </header> <div class="dokan-info"> <strong><?php _e('Note:', 'dokan'); ?> </strong> <?php _e('This order has products from multiple vendors/sellers. So we divided this order into multiple seller orders. Each order will be handled by their respective seller independently.', 'dokan'); ?> </div> <table class="shop_table my_account_orders table table-striped"> <thead> <tr> <th class="order-number"><span class="nobr"><?php _e('Order', 'dokan'); ?> </span></th> <th class="order-date"><span class="nobr"><?php _e('Date', 'dokan'); ?> </span></th> <th class="order-status"><span class="nobr"><?php _e('Status', 'dokan'); ?> </span></th> <th class="order-total"><span class="nobr"><?php _e('Total', 'dokan'); ?> </span></th> <th class="order-actions"> </th> </tr> </thead> <tbody> <?php $statuses = wc_get_order_statuses(); foreach ($sub_orders as $order_post) { $order = new WC_Order($order_post->ID); $item_count = $order->get_item_count(); ?> <tr class="order"> <td class="order-number"> <a href="<?php echo $order->get_view_order_url(); ?> "> <?php echo $order->get_order_number(); ?> </a> </td> <td class="order-date"> <time datetime="<?php echo date('Y-m-d', strtotime($order->order_date)); ?> " title="<?php echo esc_attr(strtotime($order->order_date)); ?> "><?php echo date_i18n(get_option('date_format'), strtotime($order->order_date)); ?> </time> </td> <td class="order-status" style="text-align:left; white-space:nowrap;"> <?php echo isset($statuses[$order->post_status]) ? $statuses[$order->post_status] : $order->post_status; ?> </td> <td class="order-total"> <?php echo sprintf(_n('%s for %s item', '%s for %s items', $item_count, 'woocommerce'), $order->get_formatted_order_total(), $item_count); ?> </td> <td class="order-actions"> <?php $actions = array(); $actions['view'] = array('url' => $order->get_view_order_url(), 'name' => __('View', 'dokan')); $actions = apply_filters('dokan_my_account_my_sub_orders_actions', $actions, $order); foreach ($actions as $key => $action) { echo '<a href="' . esc_url($action['url']) . '" class="button ' . sanitize_html_class($key) . '">' . esc_html($action['name']) . '</a>'; } ?> </td> </tr> <?php } ?> </tbody> </table> <?php }
function my_method($order_id) { $order = new WC_Order($order_id); error_log($order->get_view_order_url()); }
/** * This part is returnurl function for the payment gateway * * @global mixed $woocommerce */ function check_dragonpay_response_returnurl() { global $woocommerce; $amount = $_POST['amount']; $orderid = $_POST['orderid']; $appcode = $_POST['appcode']; $tranID = $_POST['tranID']; $domain = $_POST['domain']; $status = $_POST['status']; $currency = $_POST['currency']; $paydate = $_POST['paydate']; $channel = $_POST['channel']; $skey = $_POST['skey']; $vkey = $this->password; $order = new WC_Order($orderid); $key0 = md5($tranID . $orderid . $status . $domain . $amount . $currency); $key1 = md5($paydate . $domain . $key0 . $appcode . $vkey); $referer = "<br>Referer: ReturnURL"; if ($status == "00") { // Invalid transaction if ($skey != $key1) { $order->add_order_note('Dragonpay Payment Status: FAILED' . '<br>Transaction ID: ' . $tranID . $referer); $order->update_status('failed', sprintf(__('Payment %s via Dragonpay.', 'woocommerce'), $tranID)); $woocommerce->cart->empty_cart(); wp_redirect($order->get_view_order_url()); //wp_redirect($order->get_cancel_order_url()); } else { $order->add_order_note('Dragonpay Payment Status: SUCCESSFUL' . '<br>Transaction ID: ' . $tranID . $referer); $order->payment_complete(); wp_redirect($order->get_checkout_order_received_url()); } exit; } else { if ($status == "22") { $order->add_order_note('Dragonpay Payment Status: Invalid Transaction' . '<br>Transaction ID: ' . $tranID . $referer); $order->update_status('pending', sprintf(__('Payment %s via Dragonpay.', 'woocommerce'), $tranID)); $order->payment_complete($tranID); wp_redirect($order->get_view_order_url()); exit; } else { if ($status == "11") { //status 11 which is failed $order->add_order_note('Dragonpay Payment Status: FAILED' . '<br>Transaction ID: ' . $tranID . $referer); $order->update_status('failed', sprintf(__('Payment %s via Dragonpay.', 'woocommerce'), $tranID)); //$order->payment_complete(); $woocommerce->cart->empty_cart(); wp_redirect($order->get_view_order_url()); //wp_redirect($order->get_cancel_order_url()); exit; } else { //invalid transaction $order->add_order_note('Dragonpay Payment Status: FAILED' . '<br>Transaction ID: ' . $tranID . $referer); $order->update_status('failed', sprintf(__('Payment %s via Dragonpay.', 'woocommerce'), $tranID)); $woocommerce->cart->empty_cart(); wp_redirect($order->get_view_order_url()); //wp_redirect($order->get_cancel_order_url()); exit; } } } }
foreach ($customer_orders as $customer_order) { if (version_compare($woocommerce->version, '2.2.0') >= 0) { $order = new WC_Order($customer_order); $status = $order->get_status(); $status_name = wc_get_order_status_name($status); } else { $order = new WC_Order(); $order->populate($customer_order); $status = get_term_by('slug', $order->status, 'shop_order_status'); $status_name = $status->name; } ?> <tr class="order"> <td class="order-number" width="1%"> <a href="<?php echo $order->get_view_order_url(); ?> "> <?php echo $order->get_order_number(); ?> </a> </td> <td class="order-date"> <time datetime="<?php echo date('Y-m-d', strtotime($order->order_date)); ?> " title="<?php echo esc_attr(strtotime($order->order_date)); ?> "><?php
public function get_order_info() { global $dvin_qlist_products; //for admin message, replace the order info with right info otherwise space $order_info = apply_filters('dvin_wcql_order_info_str', __('Order Links(%s):<a href="%s">View</a> | <a href="%s">Edit</a> | <a href="%s">CheckOut</a>', 'dvinwcql')); $order_obj = new WC_Order($this->order_id); $order_edit_url = admin_url('post.php?post=' . absint($this->order_id) . '&action=edit'); //$order_obj->get_view_order_url(); return sprintf($order_info, $this->order_id, $order_obj->get_view_order_url(), $order_edit_url, $order_obj->get_checkout_payment_url()); }
/** * Thank you page message. * * @return string */ public function thankyou_page($order_id) { global $woocommerce; $order = new WC_Order($order_id); if (defined('WC_VERSION') && version_compare(WC_VERSION, '2.1', '>=')) { $order_url = $order->get_view_order_url(); } else { $order_url = add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('view_order'))); } if ($order->status == 'processing' || $order->status == 'completed') { echo '<div class="woocommerce-message"><a href="' . esc_url($order_url) . '" class="button" style="display: block !important; visibility: visible !important;">' . __('View order details', 'cielo-woocommerce') . '</a>' . sprintf(__('Your payment has been received successfully.', 'cielo-woocommerce'), woocommerce_price($order->order_total)) . '<br />' . __('The authorization code was generated.', 'cielo-woocommerce') . '</div>'; } else { echo '<div class="woocommerce-info">' . sprintf(__('For more information or questions regarding your order, go to the %s.', 'cielo-woocommerce'), '<a href="' . esc_url($order_url) . '">' . __('order details page', 'cielo-woocommerce') . '</a>') . '</div>'; } }
_e('Total', 'dokan'); ?> </span></th> <th class="order-actions"> </th> </tr> </thead> <tbody> <?php foreach ($sub_orders as $order_post) { $order = new WC_Order($order_post->ID); $item_count = $order->get_item_count(); ?> <tr class="order"> <td class="order-number"> <a href="<?php echo $order->get_view_order_url(); ?> "> <?php echo $order->get_order_number(); ?> </a> </td> <td class="order-date"> <time datetime="<?php echo date('Y-m-d', strtotime($order->order_date)); ?> " title="<?php echo esc_attr(strtotime($order->order_date)); ?> "><?php
function wccs_file_uploader_front_end($order_id) { global $wpdb, $thepostid, $theorder, $woocommerce, $post; $order = new WC_Order($order_id); $options = get_option('wccs_settings'); $length = empty($options['checkness']['file_upload_number']) ? 'this.files.length' : $options['checkness']['file_upload_number']; $file_types = explode(",", $options['checkness']['file_types']); $number_of_types = count($file_types); $prefix = 'wc-'; if (empty($options['checkness']['upload_os']) || $order->post_status == $prefix . $options['checkness']['upload_os']) { $upload_dir = wp_upload_dir(); $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $order_id); ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('#wccm_save_order_submit').click(function() { $(".wccm_results").html("Deleting files, please wait...."); var ajaxurl = '<?php echo admin_url('/admin-ajax.php'); ?> '; data = { action: 'update_attachment_wccm', product_image_gallery : $('#product_image_gallery').val(), wccm_default_keys_load : $('#wccm_default_keys_load').val() }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php $.post(ajaxurl, data, function(response) { $(".wccm_results").html(response); }); }); }); </script> <?php wp_enqueue_style('wccm_upload_file_style', plugins_url('includes/classes/file_upload/file_editing_table.css', WOOCCM_RELPATH)); ?> <h2><?php echo empty($options['checkness']['upload_title']) ? 'Order Uploaded Files' : esc_attr($options['checkness']['upload_title']); ?> </h2> <div class="woocommerce_order_items_wrapper front_end"> <table class="woocommerce_order_items front_end"> <thead> <tr> <th style="width:12%"><?php _e('File Image', 'woocommerce-checkout-manager'); ?> </th> <th style="width:10%"><?php _e('Action', 'woocommerce-checkout-manager'); ?> </th> <th style="width:12%"><?php _e('Width x Height', 'woocommerce-checkout-manager'); ?> </th> <th style="width:8%"><?php _e('Extension', 'woocommerce-checkout-manager'); ?> </th> <th style="width:15%;text-align: center;"><?php _e('ID #', 'woocommerce-checkout-manager'); ?> </th> <th style="width:4%"><?php _e('Link', 'woocommerce-checkout-manager'); ?> </th> <th style="width:30%;text-align: center;"><?php _e('Name', 'woocommerce-checkout-manager'); ?> </th> </tr> </thead> <tbody class="product_images front_end"> <?php $attachment_args = get_posts($args); if ($attachment_args) { foreach ($attachment_args as $attachment) { $array[] = $attachment->ID; } $default_wccm_values = implode(',', $array); $product_image_gallery = implode(',', $array); } $attachments = array_filter(explode(',', $product_image_gallery)); if ($attachments) { foreach ($attachments as $attachment_id) { $image_attributes = wp_get_attachment_url($attachment_id); $image_attributes2 = wp_get_attachment_image_src($attachment_id); $filename = basename($image_attributes); $wp_filetype = wp_check_filetype($filename); $value_declear = array_diff(explode(',', $default_wccm_values), explode(',', $attachment_id)); echo ' <tr class="image wccm_filesli wccmv_' . esc_attr($attachment_id) . '"> <td style="display:none;"> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery(".wccmx_' . esc_attr($attachment_id) . '").click(function(){ jQuery(".wccmv_' . esc_attr($attachment_id) . '").hide(); jQuery("#product_image_gallery").val(jQuery("#product_image_gallery").val().replace("' . esc_attr($attachment_id) . '", "")); }); }); </script> </td> <td>' . wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), true)) . '</td> <td> <a class="delete tips wccm_delete wccmx_' . esc_attr($attachment_id) . '" data-tip="' . __('Delete image', 'woocommerce') . '">' . __('Delete', 'woocommerce') . '</a> </td> <td>'; if ($image_attributes2[1] == '') { echo '-'; } else { echo $image_attributes2[1] . ' x ' . $image_attributes2[2]; } echo ' </td> <td>' . $wp_filetype['ext'] . '</td> <td>' . $attachment_id . '</td> <td>' . wp_get_attachment_link($attachment_id, '', false, false, 'Link') . '</td> <td>' . preg_replace('/\\.[^.]+$/', '', $filename) . '</td> </tr>'; } } else { echo ' <tr> <td colspan="7">No uploaded files have been assigned to this Order.</td> </tr> '; } ?> </tbody> <input type="hidden" class="wccm_add_to_list" id="product_image_gallery" name="product_image_gallery" value="<?php echo esc_attr($product_image_gallery); ?> " /> <input type="hidden" id="wccm_default_keys_load" name="wccm_default_keys_load" value="<?php echo esc_attr($default_wccm_values); ?> " /> </table> <!-- .woocommerce_order_items --> </div> <!-- .woocommerce_order_items_wrapper --> <button type="button" id="wccm_save_order_submit" class="file_upload_delete wooccm-btn wooccm-btn-danger delete">Confirm Delete</button> <span id="wccm_uploader_select"> <input type="file" style="display:none;" name="files_wccm" id="files_wccm" multiple /> <button type="button" class="file_upload_account wooccm-btn wooccm-btn-primary start" id="files_button_wccm">Upload Files</button> </span> <!-- #wccm_uploader_select --> <div class="wccm_results front_end"></div> <div class="clear"></div> <?php // script for uploading the files echo ' <script type="text/javascript"> jQuery(document).ready(function($){ (function post_image_content() { var input = document.getElementById("files_wccm"), formdata = false; $("#files_button_wccm").click( function(){ $("#wccm_uploader_select input[type=file]").click(); return false; }); if (window.FormData) { formdata = new FormData(); } input.addEventListener("change", function (evt) { $("#wccm_uploader_select").block({message: null, overlayCSS: {background: "#fff url(" + woocommerce_params.plugin_url + "/assets/images/ajax-loader.gif) no-repeat center", opacity: 0.6}}); $("#wccm_uploader_select").block({message: null, overlayCSS: {background: "#fff url(" + woocommerce_params.ajax_loader_url + ") no-repeat center", opacity: 0.6}}); var length = ' . $length . '; var file_array = ' . wooccm_js_array($file_types) . '; var wooempt = ' . $file_types . '; for ( i = 0; i < length; i++ ) { file = this.files[i]; for(x=0; x < ' . $number_of_types . '; x++){ if( !wooempt || file.type.match(file_array[x]) ) { if (formdata) { formdata.append("files_wccm[]",file); } } } } if (formdata) { $.ajax({ url: "' . admin_url('/admin-ajax.php?action=wccs_upload_file_func&order_id=' . $order_id . '&name=files_wccm') . '", type: "POST", data: formdata, processData: false, contentType: false, success: function (res) { $("#files_wccm").show(); $.ajax({ url: "' . $order->get_view_order_url() . '", data: {}, success: function (data) { $("div.woocommerce_order_items_wrapper.front_end").html($(data).find("div.woocommerce_order_items_wrapper.front_end")); jQuery("#wccm_uploader_select").unblock(); }, dataType: "html" }); } }); } }, false); } ()); }); </script>'; // end script // ------------ } }