Esempio n. 1
0
 /**
  * @param Wc_Order $order
  * @param Mollie_API_Object_Payment $payment
  */
 protected function onWebhookPaid(Wc_Order $order, Mollie_API_Object_Payment $payment)
 {
     Mollie_WC_Plugin::debug(__METHOD__ . ' called.');
     // Woocommerce 2.2.0 has the option to store the Payment transaction id.
     $woo_version = get_option('woocommerce_version', 'Unknown');
     if (version_compare($woo_version, '2.2.0', '>=')) {
         $order->payment_complete($payment->id);
     } else {
         $order->payment_complete();
     }
     $order->add_order_note(sprintf(__('Order completed using %s payment (%s).', 'mollie-payments-for-woocommerce'), $this->method_title, $payment->id . ($payment->mode == 'test' ? ' - ' . __('test mode', 'mollie-payments-for-woocommerce') : '')));
 }
 /**
  * Display Order information
  * 
  * Handles to display buyers information
  * 
  * @package WooCommerce - PDF Vouchers
  * @since 2.3.6
  */
 public function woo_vou_display_order_info_html($order_id, $type = 'html')
 {
     $order_details_html = '';
     //get order
     $order = new Wc_Order($order_id);
     //get order date
     $order_date = $order->order_date;
     //get payment method
     $payment_method = $order->payment_method_title;
     //Order title
     $order_total = esc_html(strip_tags($order->get_formatted_order_total()));
     //Order discount
     $order_discount = wc_price($order->get_total_discount(), array('currency' => $order->get_order_currency()));
     if ($type == 'html') {
         $order_id = '<a href="' . esc_url(admin_url('post.php?post=' . absint($order_id) . '&action=edit')) . '">' . $order_id . '</a>';
     }
     if ($type == 'csv') {
         $order_details_html .= 'ID : ' . $order_id . "\n";
         $order_details_html .= 'Order Date : ' . $order_date . "\n";
         $order_details_html .= 'Payment Method : ' . $payment_method . "\n";
         $order_details_html .= 'Order Total : 	' . $order_total . "\n";
         $order_details_html .= 'Order Discount :' . strip_tags($order_discount);
     } else {
         $order_details_html .= '<table>';
         $order_details_html .= '<tr><td style="font-weight:bold;">' . __('ID:', 'woovoucher') . '</td><td>' . $order_id . '</td></tr>';
         $order_details_html .= '<tr><td style="font-weight:bold;">' . __('Order Date:', 'woovoucher') . '</td><td>' . $order_date . '</td></tr>';
         $order_details_html .= '<tr><td style="font-weight:bold;">' . __('Payment Method:', 'woovoucher') . '</td><td>' . $payment_method . '</td></tr>';
         $order_details_html .= '<tr><td style="font-weight:bold;">' . __('Order Total:', 'woovoucher') . '</td><td>' . $order_total . '</td></tr>';
         $order_details_html .= '<tr><td style="font-weight:bold;">' . __('Order Discount:', 'woovoucher') . '</td><td>' . $order_discount . '</td></tr>';
         $order_details_html .= '</table>';
     }
     return apply_filters('woo_vou_display_order_info_html', $order_details_html, $order_id, $type);
 }
<?php

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
global $woo_vou_model, $post;
//model class
$model = $woo_vou_model;
$order_id = isset($post->ID) ? $post->ID : '';
$allorderdata = $model->woo_vou_get_all_ordered_data($order_id);
//get cart details
$cart_details = new Wc_Order($order_id);
$order_items = $cart_details->get_items();
//get meta prefix
$prefix = WOO_VOU_META_PREFIX;
if (!empty($order_items)) {
    // Check cart details are not empty
    ?>
	<table class="widefat woo-vou-history-table">
		<tr class="woo-vou-history-title-row">
			<th width="8%"><?php 
    echo __('Logo', 'woovoucher');
    ?>
</th>
			<th width="17%"><?php 
    echo __('Product Title', 'woovoucher');
    ?>
</th>
			<th width="15%"><?php 
    echo __('Code', 'woovoucher');
 /**
  * Adding Hooks
  *
  * Adding proper hoocks for the discount codes
  *
  * @package WooCommerce - PDF Vouchers
  * @since   2.3.1
  */
 public function woo_vou_my_pdf_vouchers_download_link($downloads = array())
 {
     //get prefix
     $prefix = WOO_VOU_META_PREFIX;
     if (is_user_logged_in()) {
         //If user is logged in
         //Get user ID
         $user_id = get_current_user_id();
         //Get User Order Arguments
         $args = array('numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => $user_id, 'post_type' => WOO_VOU_MAIN_SHOP_POST_TYPE, 'post_status' => array('wc-completed'), 'meta_query' => array(array('key' => $prefix . 'meta_order_details', 'compare' => 'EXISTS')));
         //user orders
         $user_orders = get_posts($args);
         if (!empty($user_orders)) {
             //If orders are not empty
             foreach ($user_orders as $user_order) {
                 //Get order ID
                 $order_id = isset($user_order->ID) ? $user_order->ID : '';
                 if (!empty($order_id)) {
                     //Order it not empty
                     global $vou_order;
                     //Set global order ID
                     $vou_order = $order_id;
                     //Get cart details
                     $cart_details = new Wc_Order($order_id);
                     $order_items = $cart_details->get_items();
                     $order_date = isset($cart_details->order_date) ? $cart_details->order_date : '';
                     $order_date = date('d-m-y', strtotime($order_date));
                     if (!empty($order_items)) {
                         // Check cart details are not empty
                         foreach ($order_items as $item_id => $product_data) {
                             //Get product from Item ( It is required otherwise multipdf voucher link not work )
                             $_product = apply_filters('woocommerce_order_item_product', $cart_details->get_product_from_item($product_data), $product_data);
                             if (!$_product) {
                                 //If product deleted
                                 $download_file_data = array();
                             } else {
                                 //Get download files
                                 $download_file_data = $cart_details->get_item_downloads($product_data);
                             }
                             //Get voucher codes
                             $codes = wc_get_order_item_meta($item_id, $prefix . 'codes');
                             if (!empty($download_file_data) && !empty($codes)) {
                                 //If download exist and code is not empty
                                 foreach ($download_file_data as $key => $download_file) {
                                     //check download key is voucher key or not
                                     $check_key = strpos($key, 'woo_vou_pdf_');
                                     //get voucher number
                                     $voucher_number = str_replace('woo_vou_pdf_', '', $key);
                                     if (empty($voucher_number)) {
                                         //If empty voucher number
                                         $voucher_number = 1;
                                     }
                                     if (!empty($download_file) && $check_key !== false) {
                                         //Get download URL
                                         $download_url = $download_file['download_url'];
                                         //add arguments array
                                         $add_arguments = array('item_id' => $item_id);
                                         //PDF Download URL
                                         $download_url = add_query_arg($add_arguments, $download_url);
                                         //get product name
                                         $product_name = isset($_product->post->post_title) ? $_product->post->post_title : '';
                                         //Download file arguments
                                         $download_args = array('download_url' => $download_url, 'download_name' => $product_name . ' - ' . $download_file['name'] . ' ' . $voucher_number . ' ( ' . $order_date . ' )', 'downloads_remaining' => '');
                                         //append voucher download to downloads array
                                         $downloads[] = $download_args;
                                     }
                                 }
                             }
                         }
                     }
                     //reset global order ID
                     $vou_order = 0;
                 }
             }
         }
     }
     return $downloads;
 }