/**
 * Add `item_count` column data
 *
 * @param array $order_data the original column data
 * @param \WC_Order $order the order object
 * @param \WC_Customer_Order_CSV_Export_Generator $csv_generator the generator instance
 * @return array - the updated column data
 */
function sv_wc_csv_export_add_item_count_data($order_data, $order, $csv_generator)
{
    $new_order_data = array();
    $one_row_per_item = false;
    $custom_data = array('item_count' => $order->get_item_count());
    if (version_compare(wc_customer_order_csv_export()->get_version(), '4.0.0', '<')) {
        // pre 4.0 compatibility
        $one_row_per_item = 'default_one_row_per_item' === $csv_generator->order_format || 'legacy_one_row_per_item' === $csv_generator->order_format;
    } elseif (isset($csv_generator->format_definition)) {
        // post 4.0 (requires 4.0.3+)
        $one_row_per_item = 'item' === $csv_generator->format_definition['row_type'];
    }
    if ($one_row_per_item) {
        foreach ($order_data as $data) {
            $new_order_data[] = array_merge((array) $data, $custom_data);
        }
    } else {
        $new_order_data = array_merge($order_data, $custom_data);
    }
    return $new_order_data;
}
 public function process_payment($order_id)
 {
     if (!$this->is_currency_supported()) {
         throw new Exception(__('You cannot use this currency with LINE Pay.', 'wc-payment-gateway-line-pay'));
     }
     $order = new WC_Order($order_id);
     $items = $order->get_items();
     reset($items);
     $first_item = $items[key($items)];
     $item_name = $first_item['name'];
     $item_count = $order->get_item_count();
     $product_name = $item_name;
     if ($item_count > 1) {
         $product_name .= sprintf(__(' and %s others', 'wc-payment-gateway-line-pay'), $item_count - 1);
     }
     $response_data = $this->client->reserve($product_name, $this->product_image_url, $order->get_total(), get_woocommerce_currency(), add_query_arg('wc-api', 'linepay_confirm_url', home_url('/')), $order->get_checkout_payment_url(), $order_id, $this->get_option('langCd'));
     if ($response_data->returnCode != '0000') {
         throw new Exception(sprintf(__('Incorrect parameters were passed during checkout. Please contact site administrator. Return code: %s', 'wc-payment-gateway-line-pay'), $response_data->returnCode));
     }
     update_post_meta($order_id, '_hpd_linepay_transactionId', $response_data->info->transactionId);
     WC()->cart->empty_cart();
     return array('result' => 'success', 'redirect' => $response_data->info->paymentUrl->web);
 }
				<th class="order-actions">&nbsp;</th>
			</tr>
		</thead>

		<tbody><?php 
    //echo "hiiiiiiii";
    //print_r($order_ids);
    //$user_product_bought=fused_has_user_bought(6,$order_userids);
    //print_r($user_product_bought);
    //$order = new WC_Order();
    //print_r($order_userids);
    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 esc_url(add_query_arg('order', $order->id, get_permalink(woocommerce_get_page_id('view_order'))));
        ?>
">
							<?php 
        echo $order->get_order_number();
        ?>
						</a>
					</td>
					<td class="order-date">
						<time datetime="<?php 
        echo date('Y-m-d', strtotime($order->order_date));
 public function make_pickup_request($order_id)
 {
     $order = new WC_Order($order_id);
     $soapClient = new SoapClient(__DIR__ . '/Shipping.wsdl');
     date_default_timezone_set('Asia/Calcutta');
     $time = current_time('H', true);
     $day = current_time('N');
     //If greater than 3:00 PM
     if ($time >= 15) {
         $offset = " + 2 days";
         $order->add_order_note('Order placed after 3:00 PM cut off time');
     } else {
         $offset = ' + 1 days';
         $order->add_order_note('Order placed before 3:00 PM cut off time');
     }
     switch ($day) {
         case '5':
             $offset = ' + 3 days';
             break;
         case '6':
             $offset = ' + 2 days';
             break;
         case '7':
             $offset = ' + 2 days';
             break;
         default:
             break;
     }
     $format = 'Y-m-d\\TH:i:s';
     $pickupdate = date($format, strtotime(date("Y-m-d H:i:s", mktime(11, 30, 0)) . $offset));
     $readytime = date($format, strtotime(date("Y-m-d H:i:s", mktime(12, 30, 0)) . $offset));
     $lastpickuptime = strtotime(date($format, strtotime(date("Y-m-d H:i:s", mktime(17, 30, 0)) . $offset)));
     $closingtime = strtotime(date($format, strtotime(date("Y-m-d H:i:s", mktime(19, 00, 0)) . $offset)));
     $shippingdatetime = $pickupdate;
     $order->add_order_note("Pick up request time:" . date("Y-m-d H:i:s", strtotime($pickupdate)));
     $params = array('Pickup' => array('PickupAddress' => array('Line1' => $this->address_1, 'Line2' => $this->address_2, 'Line3' => $this->address_3, 'City' => $this->city, 'StateOrProvinceCode' => $this->state, 'PostCode' => $this->postcode, 'CountryCode' => $this->country), 'PickupContact' => array('Department' => $this->dept, 'PersonName' => $this->contact_name, 'Title' => $this->contact_title, 'CompanyName' => $this->company_name, 'PhoneNumber1' => $this->phonenumber1, 'PhoneNumber1Ext' => $this->phonenumber1ext, 'PhoneNumber2' => $this->phonenumber2, 'PhoneNumber2Ext' => $this->phonenumber2ext, 'FaxNumber' => $this->faxnumber, 'CellPhone' => $this->cellphone, 'EmailAddress' => $this->emailaddress, 'Type' => ''), 'PickupLocation' => 'Reception', 'PickupDate' => $pickupdate, 'ReadyTime' => $readytime, 'LastPickupTime' => $lastpickuptime, 'ClosingTime' => $closingtime, 'ShippingDateTime' => $shippingdatetime, 'Comments' => '', 'Reference1' => $order_id, 'Reference2' => '', 'Vehicle' => '', 'Status' => 'Ready', 'PickupItems' => array('PickupItemDetail' => array('ProductGroup' => 'DOM', 'ProductType' => 'ONP', 'Payment' => 'P', 'NumberOfShipments' => 1, 'PackageType' => '', 'NumberOfPieces' => $order->get_item_count(), 'Comments' => '', 'ShipmentWeight' => array('Value' => 0.5, 'Unit' => 'Kg'), 'ShipmentVolume' => array('Value' => 0.5, 'Unit' => 'Kg'), 'CashAmount' => array('Value' => 0, 'CurrencyCode' => ''), 'ExtraCharges' => array('Value' => 0, 'CurrencyCode' => ''), 'ShipmentDimensions' => array('Length' => 0, 'Width' => 0, 'Height' => 0, 'Unit' => 'cm')))), 'ClientInfo' => array('AccountCountryCode' => $this->country, 'AccountEntity' => $this->entity, 'AccountNumber' => $this->account_num, 'AccountPin' => $this->pin, 'UserName' => $this->username, 'Password' => $this->password, 'Version' => 'v1.0'), 'Transaction' => array('Reference1' => $order_id, 'Reference2' => '', 'Reference3' => '', 'Reference4' => '', 'Reference5' => ''), 'LabelInfo' => Null);
     update_post_meta($order_id, 'aramex_pickup_request', json_encode($params));
     try {
         $auth_call = $soapClient->CreatePickup($params);
         update_post_meta($order_id, 'aramex_pickup_response', json_encode($auth_call));
         if (empty($auth_call->HasErrors) || $auth_call->HasErrors == 0) {
             $pickup_id = $auth_call->ProcessedPickup->ID;
             $pickup_guid = $auth_call->ProcessedPickup->GUID;
             $order->add_order_note("Aramex Pickup Request Successful <br> \n                    Pickup Request ID:" . $pickup_id . "<br>Pickup Request GUID:" . $pickup_guid);
             update_post_meta($order_id, 'pickup_id', $pickup_id);
             update_post_meta($order_id, 'pickup_guid', $pickup_guid);
         } else {
             $msg = "Aramex Pickup Request Failed due to the following error(s):<br>";
             foreach ($auth_call->Notifications as $notification) {
                 $msg .= "Error " . $notification->Code . ": " . $notification->Message . "<br>";
             }
             $order->add_order_note($msg);
             if ($this->verbose_reporting == true) {
                 wp_mail(get_bloginfo('admin_email'), 'Pick up request failed. Order ID:' . $order_id, $msg);
             }
         }
     } catch (SoapFault $fault) {
         $order->add_order_note("Failed creating Aramex pickup request. Error:" . $fault->faultstring);
         $message = "The system was unable to create an Aramex pickup request for Order ID" . $order_id . "/r/n The error we received from Aramex is as follows:/r/n" . $fault->faultstring . "/r/n";
         if ($this->verbose_reporting == true) {
             wp_mail(get_bloginfo('admin_email'), 'Pick up request failed. Order ID:' . $order_id, $message);
         }
     }
 }
 /**
  * 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);
 }
Exemple #6
0
 /**
  * Test: get_item_count
  */
 function test_get_item_count()
 {
     $object = new WC_Order();
     $item_1 = new WC_Order_Item_Product();
     $item_1->set_props(array('product' => WC_Helper_Product::create_simple_product(), 'quantity' => 4));
     $item_2 = new WC_Order_Item_Product();
     $item_2->set_props(array('product' => WC_Helper_Product::create_simple_product(), 'quantity' => 2));
     $object->add_item($item_1);
     $object->add_item($item_2);
     $object->save();
     $this->assertEquals(6, $object->get_item_count());
 }
Exemple #7
0
    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('&times; %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 
        }
    }
 protected function get_order_name(\WC_Order $order)
 {
     $item_count = $order->get_item_count();
     if (!$item_count) {
         throw new \LogicException('items are empty!');
     }
     $items = $order->get_items();
     $first_item = reset($items);
     if ($item_count == 1) {
         $order_name = $first_item['name'];
     } else {
         $fmt = _n('외 %d개 상품', '외 %d개 상품들', $item_count - 1, 'wskl');
         $order_name = $first_item['name'] . sprintf($fmt, $item_count - 1);
     }
     return $order_name;
 }
function check_type_of_product($order_id)
{
    create_xero_invoice($order_id);
    if (!is_Null) {
        $order = NULL;
    }
    global $post;
    $order = new WC_Order($order_id);
    $items = $order->get_items();
    $OrderItemIds = array_keys($items);
    $numberOfItems = $order->get_item_count();
    $counter = 0;
    foreach ($items as $item) {
        $orderItemId = $OrderItemIds[$counter];
        $product = $order->get_product_from_item($item);
        $productAttributes = $product->get_attributes();
        if (!is_null($productAttributes['webinarid']['value'])) {
            $webinarId = $productAttributes['webinarid']['value'];
        } else {
            $webinarId = NULL;
        }
        if (!is_null($webinarId)) {
            $billingAddress = $order->get_formatted_billing_address();
            $firstName = $item['item_meta']['firstName'][0];
            $lastName = $item['item_meta']['lastName'][0];
            $email = $item['item_meta']['email'][0];
            $citrix = new CitrixAPI('5d8ab3cea37233d7d97dc1db5994fc9c', '8876575418305764356');
            $registerAttendee = $citrix->createRegistrant($webinarId, $firstName, $lastName, $email);
        } else {
            $userID = $order->customer_user;
            $adviserEmail = $order->billing_email;
            $billingAddressFormatted = $order->get_formatted_billing_address();
            $billingAddress = $order->get_billing_address();
            $billingName = $order->billing_first_name . ' ' . $order->billing_last_name;
            //$billingFormatted;//
            $billingCompany = $order->billing_company;
            $billing_phone = $order->billing_phone;
            if (!is_null($order->billing_address_1)) {
                $billingAddress1 = $order->billing_address_1;
            } else {
                $billingAddress1 = '';
            }
            if (!is_null($order->billing_address_2)) {
                $billingAddress2 = $order->billing_address_2;
            } else {
                $billingAddress2 = '';
            }
            if (!is_null($order->billing_city)) {
                $billingCity = $order->billing_city;
            } else {
                $billingCity = '';
            }
            if (!is_null($order->billing_state)) {
                $billingState = $order->billing_state;
            } else {
                $billingState = '';
            }
            if (!is_null($order->billing_postcode)) {
                $billingPostcode = $order->billing_postcode;
            } else {
                $billingPostcode = '';
            }
            //if virtual product, post data to server as well.
            //$isVirtual = $product->is_virtual();
            //if($isVirtual){
            //$emailToAdmin = 0;
            //post_item_data_to_server($order_id, $orderItemId, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode, $emailToAdmin);
            //}
            //24 April 2014 - Altered so that all orders post data when complete so that I can auto-complete all orders, not just electronic ones.
            post_item_data_to_server($order_id, $orderItemId, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode, $emailToAdmin);
            generate_docs_on_data_server($order_id, $orderItemId, $product, $adviserEmail, $userID, $item, $billingAddressFormatted, $billingAddress, $billingName, $billingCompany, $billing_phone, $billingAddress1, $billingAddress2, $billingCity, $billingState, $billingPostcode);
        }
        $counter = $counter + 1;
    }
    $order = NULL;
}
Exemple #10
0
/**
 * 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">&nbsp;</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 _woocommercecivicrm_customer_orders($uid)
{
    $customer_orders = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array('meta_key' => '_customer_user', 'meta_value' => $uid, 'post_type' => 'shop_order', 'post_status' => array_keys(wc_get_order_statuses()))));
    $site_url = get_site_url();
    $orders = array();
    foreach ($customer_orders as $customer_order) {
        $order = new WC_Order();
        $order->populate($customer_order);
        $status = get_term_by('slug', $order->status, 'shop_order_status');
        //$items = $order->get_items();
        //print_r ($items);
        $item_count = $order->get_item_count();
        $total = $order->get_total();
        $orders[$customer_order->ID]['order_number'] = $order->get_order_number();
        $orders[$customer_order->ID]['order_date'] = date('Y-m-d', strtotime($order->order_date));
        $orders[$customer_order->ID]['order_billing_name'] = $order->get_formatted_billing_full_name();
        $orders[$customer_order->ID]['order_shipping_name'] = $order->get_formatted_shipping_full_name();
        $orders[$customer_order->ID]['item_count'] = $item_count;
        $orders[$customer_order->ID]['order_total'] = $total;
        $orders[$customer_order->ID]['order_link'] = $site_url . "/wp-admin/post.php?action=edit&post=" . $order->get_order_number();
        //$orders['order_total'] = $order->get_order_number();
    }
    return $orders;
}
Exemple #12
0
 /**
  * Tracks a checkout
  * @return none
  */
 function track_checkout($order_id, $params)
 {
     $this->user["wc cart size"] = 0;
     $this->user["wc cart value"] = 0;
     if (!is_user_logged_in()) {
         $this->user['name'] = $params["billing_first_name"] . " " . $params["billing_last_name"];
         $this->user['email'] = $params["billing_email"];
         $this->woopra->identify($this->user);
     } else {
         $this->woopra_detect();
     }
     global $woocommerce;
     $cart = $woocommerce->cart;
     $order = new WC_Order($order_id);
     $new_params = array("cart subtotal" => $cart->subtotal, "cart value" => $order->get_total(), "cart size" => $order->get_item_count(), "payment method" => $params["payment_method"], "shipping method" => $order->get_shipping_method(), "order discount" => $order->get_total_discount(), "order number" => $order->get_order_number());
     $this->woopra->track('wc checkout', $new_params, true);
 }
 /**
  * @used-by process_payment
  *
  * @param WC_Order $order
  *
  * @return array wc_remote_post 함수에 사용될 파라미터를 담음.
  */
 private function get_api_arguments(WC_Order &$order)
 {
     $item_count = $order->get_item_count();
     if (!$item_count) {
         throw new \LogicException('items are empty!');
     }
     $items = $order->get_items();
     $first_item = reset($items);
     if ($item_count == 1) {
         $goods_name = $first_item['name'];
     } else {
         $fmt = _n('외 %d개 상품', '외 %d개 상품들', $item_count - 1, 'wskl');
         $goods_name = $first_item['name'] . sprintf($fmt, $item_count - 1);
     }
     // from wskl's pay slugs to payapp's pay type
     $idx = array_search($this->checkout_method, array_keys(WSKL_Payment_Gates::get_checkout_methods()));
     $payapp_pay_types = array('card', 'rbank', 'vbank', 'phone');
     $pay_type = $payapp_pay_types[$idx];
     $feedback_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'wskl-payapp-feedback', home_url('/')));
     error_log('Our feedback URL for PayApp: ' . $feedback_url);
     $args = array('sslverify' => FALSE, 'timeout' => 15, 'body' => array('cmd' => 'payrequest', 'userid' => $this->get_option('payapp_user_id'), 'goodname' => html_entity_decode($goods_name), 'price' => $order->order_total, 'recvphone' => preg_replace('/[+\\-\\s]/', '', $order->billing_phone), 'memo' => '', 'reqaddr' => '0', 'feedbackurl' => $feedback_url, 'var1' => $order->id, 'var2' => $order->order_key, 'smsuse' => 'n', 'currency' => 'krw', 'vccode' => '', 'returnurl' => '', 'openpaytype' => $pay_type, 'checkretry' => 'n'));
     return $args;
 }
function create_xero_invoice($order_id)
{
    //create Xero Invoice
    $to = '*****@*****.**';
    $subject = 'Started Xero Invoice Method';
    $message = '';
    wp_mail($to, $subject, $message);
    $data = array();
    $order = new WC_Order($order_id);
    $items = $order->get_items();
    $OrderItemIds = array_keys($items);
    $numberOfItems = $order->get_item_count();
    $data['firstName'] = $order->billing_first_name;
    $data['lastName'] = $order->billing_last_name;
    $data['emailAddress'] = $order->billing_email;
    $data['date'] = "01/01/2014";
    $data['status'] = "DRAFT";
    if (!is_null($order->billing_company)) {
        $data['name'] = $order->billing_company;
    } else {
        $data['name'] = $order->billing_first_name . ' ' . $order->billing_last_name;
    }
    if (!is_null($order->billing_address_1)) {
        $data['streetLevel'] = $order->billing_address_1;
        $data['postLevel'] = $order->billing_address_1;
    } else {
        $data['streetLevel'] = '';
        $data['postLevel'] = '';
    }
    if (!is_null($order->billing_address_2)) {
        $data['streetStreet'] = $order->billing_address_2;
        $data['postStreet'] = $order->billing_address_2;
    } else {
        $data['streetStreet'] = '';
        $data['postStreet'] = '';
    }
    if (!is_null($order->billing_city)) {
        $data['streetSuburb'] = $order->billing_city;
        $data['postSuburb'] = $order->billing_city;
    } else {
        $data['streetSuburb'] = '';
        $data['postSuburb'] = '';
    }
    if (!is_null($order->billing_state)) {
        $data['streetState'] = $order->billing_state;
        $data['postState'] = $order->billing_state;
    } else {
        $data['streetState'] = '';
        $data['postState'] = '';
    }
    if (!is_null($order->billing_postcode)) {
        $data['streetPostcode'] = $order->billing_postcode;
        $data['postPostcode'] = $order->billing_postcode;
    } else {
        $data['streetPostcode'] = '';
        $data['postPostcode'] = '';
    }
    $data['contact'] = array("Name" => $data['name'], "FirstName" => $data['firstName'], "LastName" => $data['lastName'], "EmailAddress" => $data['emailAddress'], "Addresses" => array("Address" => array("AddressType" => "STREET", "AddressLine1" => $data['streetLevel'], "AddressLine2" => $data['streetStreet'], "City" => $data['streetSuburb'], "Region" => $data['streetState'], "PostalCode" => $data['streetPostcode']), "Address" => array("AddressType" => "POBOX", "AddressLine1" => $data['postLevel'], "AddressLine2" => $data['postStreet'], "City" => $data['postSuburb'], "Region" => $data['postState'], "PostalCode" => $data['postPostcode'])));
    $counter = 0;
    $data['submitfile'] = "submit-nsf.php";
    $data['orderServiceType'] = $item['item_meta']['Service Type'][0];
    $data['Reference'] = $order_id;
    foreach ($items as $item) {
        $orderItemId = $OrderItemIds[$counter];
        $product_id = $item['product_id'];
        $product = $order->get_product_from_item($item);
        $product_sku = $product->get_sku();
        $lastTwoLetters = substr($product_sku, -2);
        if ($lastTwoLetters == "ED") {
            $data['orderServiceType'] = "Electronic Delivery";
        } elseif ($lastTwoLetters == "PD") {
            $data['orderServiceType'] = "Paper Delivery";
        } else {
            $data['orderServiceType'] = "Premium Service";
        }
        switch ($product_id) {
            case "1005":
                //NSF
                $description = "Documentation for the establishment of " . $item['item_meta']['fundName'][0];
                $itemCode = 'NSF-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'];
                $hasCompany = 0;
                break;
            case "1149":
                //NSFCOY
                $description = "Documentation for the establishment of " . $item['item_meta']['fundName'][0] . " and incorporation of " . $item['item_meta']['companyName'][0] . " " . $item['item_meta']['companySuffix'][0];
                $itemCode = 'NSFCOY-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'] - 444;
                $hasCompany = 1;
                break;
            case "1128":
                //COY
                $description = "Documentation for the incorporation of " . $item['item_meta']['companyName'][0] . " " . $item['item_meta']['companySuffix'][0];
                $itemCode = 'COY-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'] - 444;
                $hasCompany = 1;
                break;
            case "958":
                //SDV
                $description = "Documentation to update the trust deed for " . $item['item_meta']['fundName'][0];
                $itemCode = 'SDV-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'];
                $hasCompany = 0;
                break;
            case "965":
                //Borrowing
                $description = "Documentation to implement a limited recourse borrowing arrangement for " . $item['item_meta']['fundName'][0];
                $itemCode = 'LRBA-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'];
                $hasCompany = 0;
                break;
            case "1338":
                //Pension
                $description = "Documentation for the the commencement of a SMSF pension for " . $item['item_meta']['fundName'][0];
                $itemCode = 'PSN-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'];
                $hasCompany = 0;
                break;
            case "1330":
                //COT
                $description = "Documentation for the the commencement of a SMSF pension for " . $item['item_meta']['fundName'][0];
                $itemCode = 'COT-' . $lastTwoLetters;
                $taxType = "OUTPUT";
                $itemPrice = $item['line_subtotal'];
                $hasCompany = 0;
                break;
        }
        $lineItem = array("Quantity" => "1.0000", "ItemCode" => $itemCode, "Description" => $description, "UnitAmount" => $itemPrice, "TaxType" => $taxType);
        $data['lineAmountTypes'] = "Inclusive";
        $data['lineItems'] = array("LineItem" => array());
        $data['date'] = '';
        $data['lineItems']['LineItem'][] = $lineItem;
        if ($hasCompany == 1) {
            $lineItem = array("Quantity" => "1.0000", "ItemCode" => "ASIC", "Description" => "ASIC Fee for Incorporation of " . $item['item_meta']['companyName'][0] . " " . $item['item_meta']['companySuffix'][0], "UnitAmount" => "444.0000", "TaxType" => "EXEMPTOUTPUT");
            $data['lineItems']['LineItem'][] = $lineItem;
        }
    }
    $request = new WP_Http();
    $response = $request->post('http://www.paratus.com.au/wp-content/themes/goodchoice/includes/post-xero.php', array('body' => $data, 'blocking' => false));
}