当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Order::get_used_coupons方法代码示例

本文整理汇总了PHP中WC_Order::get_used_coupons方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Order::get_used_coupons方法的具体用法?PHP WC_Order::get_used_coupons怎么用?PHP WC_Order::get_used_coupons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Order的用法示例。


在下文中一共展示了WC_Order::get_used_coupons方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_financials_csv

function generate_financials_csv($export_event_id)
{
    $orders = TribeEventsTickets::get_event_attendees($export_event_id);
    $counter = 1;
    $export_financials = array();
    $temp_order_id = 0;
    $temp_product_id = 0;
    $temp_counter = 1;
    foreach ($orders as $order) {
        $number = $counter;
        $order_id = $order['order_id'];
        $order_meta = get_post_meta($order_id);
        $temp_product_id = $order['product_id'];
        $ticket = $order['ticket'];
        $purchase_date = get_the_date('F j, Y g:i a', $order_id);
        // $order_meta['_paid_date'][0];
        $purchaser_name = $order_meta['_billing_first_name'][0] . ' ' . $order_meta['_billing_last_name'][0];
        $user_id = $order_meta['_customer_user'][0];
        $purchaser_email = $order_meta['_billing_email'][0];
        $purchaser_phone = $order_meta['_billing_phone'][0];
        $company = $order_meta['_billing_company'][0];
        $address1 = $order_meta['_billing_address_1'][0];
        $address2 = $order_meta['_billing_address_2'][0];
        $address = $address1 . ', ' . $address2;
        $city = $order_meta['_billing_city'][0];
        $state = $order_meta['_billing_state'][0];
        $zip = $order_meta['_billing_postcode'][0];
        $discount = round($order_meta['_cart_discount'][0], 2);
        $total = $order_meta['_order_total'][0];
        $payment_method = $order_meta['_payment_method_title'][0];
        if ($temp_order_id == $order_id && $temp_product_id == $order['product_id']) {
            $temp_counter++;
        } else {
            $temp_counter = 1;
        }
        $attendee_first_name = $order_meta["attendee_first_name_" . $temp_product_id . "_" . $temp_counter][0];
        if (empty($attendee_first_name)) {
            $attendee_first_name = $order_meta["attendee_name_" . $temp_product_id . "_" . $temp_counter][0];
        }
        $attendee_last_name = $order_meta["attendee_last_name_" . $temp_product_id . "_" . $temp_counter][0];
        $attendee_job = $order_meta["attendee_job_title_" . $temp_product_id . "_" . $temp_counter][0];
        $attendee_phone = $order_meta["attendee_primary_phone_" . $temp_product_id . "_" . $temp_counter][0];
        $order_cst = new WC_Order($order_id);
        $order_items = $order_cst->get_items();
        foreach ($order_items as $item_id => $values) {
            $attendee_count = $values['qty'];
            break;
        }
        $coupons = $order_cst->get_used_coupons();
        $coupon = $coupons[0];
        if (!$coupon) {
            $coupon = "";
        }
        if ($discount == 0) {
            $discount = "";
        } else {
            $discount = "\$" . $discount;
        }
        $export_financials[$counter] = array($order_id, $purchase_date, $ticket, $user_id, $purchaser_name, $purchaser_email, $purchaser_phone, $company, $address, $city, $state, $zip, $attendee_first_name, $attendee_last_name, $attendee_job, $attendee_cell_phone, $attendee_work_phone, $attendee_count, $total, $payment_method, $coupon, $discount);
        $counter++;
        $temp_order_id = $order_id;
        $temp_product_id = $order['product_id'];
    }
    $event = get_post($export_event_id);
    if (!empty($export_financials)) {
        $charset = get_option('blog_charset');
        $start_date = strtotime(get_post_meta($event, '_EventStartDate', true));
        $filename = $event->post_name;
        // output headers so that the file is downloaded rather than displayed
        header("Content-Type: text/csv; charset={$charset}");
        header("Content-Disposition: attachment; filename={$filename}-fiancial-data.csv");
        // create a file pointer connected to the output stream
        $output = fopen('php://output', 'w');
        fputcsv($output, array('Order ID', 'Purchase Date', 'Ticket Name', 'User ID', 'Purchaser Name', 'Purchaser Email', 'Purchaser Phone', 'Purchaser Company', 'Address', 'City', 'State', 'Zip', 'Attendee First Name', 'Attendee Last Name', 'Job Title', 'Cell Phone', 'Work Phone', 'Number of Tickets Purchased', 'Total Paid', 'Payment Method', 'Coupon Code', 'Discount Amount'));
        // And echo the data
        foreach ($export_financials as $item) {
            fputcsv($output, $item);
        }
        fclose($output);
        exit;
    }
}
开发者ID:georgi-kovachev,项目名称:mapClass,代码行数:82,代码来源:financials-export.php

示例2: send_product_tag

function send_product_tag($order_id)
{
    $order = new WC_Order($order_id);
    $user = $order->billing_email;
    $items = $order->get_items();
    $coupons = $order->get_used_coupons();
    $traits = array('has_purchased' => 'yes');
    conveyour_identify($user, $traits);
    if (isset($coupons)) {
        foreach ($coupons as $coupon) {
            conveyour_track($user, 'used_coupon', array('coupon' => $coupon));
        }
    }
    foreach ($items as $item) {
        $product_name = $item['name'];
        $product_name_underscores = str_replace(' ', '_', $product_name);
        $product_name_sliced_and_underscored = substr($product_name_underscores, 0, 6);
        $myproduct_id = $item['product_id'];
        $my_product_name = $myproduct_id . '-' . $product_name_sliced_and_underscored;
        $product_object = new WC_Product($myproduct_id);
        $product_price = $product_object->regular_price;
        $traits = array('product' => $my_product_name, 'Item-Price' => $product_price, 'Order-ID' => $order_id);
        conveyour_track($user, 'Purchased_product', $traits);
    }
}
开发者ID:Chr15t1anRJW,项目名称:Wordpress-conveyour-hooks,代码行数:25,代码来源:conveyour-identify-and-events.php

示例3: delete_rac_coupon

 public static function delete_rac_coupon($order_id)
 {
     if ('yes' === get_option('rac_delete_coupon_after_use')) {
         $order = new WC_Order($order_id);
         $used_coupons = $order->get_used_coupons();
         foreach ($used_coupons as $coupon) {
             $coupon_ob = new WC_Coupon($coupon);
             if (get_post_meta($coupon_ob->id, 'coupon_by_rac', true) == 'yes') {
                 wp_delete_post($coupon_ob->id, true);
             }
         }
     }
 }
开发者ID:bear12345678,项目名称:keylessoption,代码行数:13,代码来源:fp_rac_coupon_deletion.php

示例4: getRequestData

/**
 * Bundle and format the order information
 * @param WC_Order $order
 * Send as much information about the order as possible to Conekta
 */
function getRequestData($order)
{
    if ($order and $order != null) {
        // custom fields
        $custom_fields = array("total_discount" => (double) $order->get_total_discount() * 100);
        // $user_id = $order->get_user_id();
        // $is_paying_customer = false;
        $order_coupons = $order->get_used_coupons();
        // if ($user_id != 0) {
        //     $custom_fields = array_merge($custom_fields, array(
        //         "is_paying_customer" => is_paying_customer($user_id)
        //     ));
        // }
        if (count($order_coupons) > 0) {
            $custom_fields = array_merge($custom_fields, array("coupon_code" => $order_coupons[0]));
        }
        return array("amount" => (double) $order->get_total() * 100, "token" => $_POST['conektaToken'], "shipping_method" => $order->get_shipping_method(), "shipping_carrier" => $order->get_shipping_method(), "shipping_cost" => (double) $order->get_total_shipping() * 100, "monthly_installments" => (int) $_POST['monthly_installments'], "currency" => strtolower(get_woocommerce_currency()), "description" => sprintf("Charge for %s", $order->billing_email), "card" => array_merge(array("name" => sprintf("%s %s", $order->billing_first_name, $order->billing_last_name), "address_line1" => $order->billing_address_1, "address_line2" => $order->billing_address_2, "billing_company" => $order->billing_company, "phone" => $order->billing_phone, "email" => $order->billing_email, "address_city" => $order->billing_city, "address_zip" => $order->billing_postcode, "address_state" => $order->billing_state, "address_country" => $order->billing_country, "shipping_address_line1" => $order->shipping_address_1, "shipping_address_line2" => $order->shipping_address_2, "shipping_phone" => $order->shipping_phone, "shipping_email" => $order->shipping_email, "shipping_address_city" => $order->shipping_city, "shipping_address_zip" => $order->shipping_postcode, "shipping_address_state" => $order->shipping_state, "shipping_address_country" => $order->shipping_country), $custom_fields));
    }
    return false;
}
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:25,代码来源:conekta_gateway_helper.php

示例5: get_iframe_html

 public function get_iframe_html($order_id = 0, $args = array())
 {
     $order = new WC_Order($order_id);
     $items = $order->get_items();
     $item_query_args = array();
     /**
      * Get total order level discount and then get average discount splitting it across all products.
      */
     // coupons
     $coupons = '';
     foreach ($order->get_used_coupons() as $coupon) {
         $item_query_args['COUPON'] .= $coupon;
     }
     $i = 0;
     foreach ($items as $item) {
         $i++;
         /**
          * Only add the product to the query arg if the data is valid
          */
         if (isset($item['product_id']) || 0 < absint($item['product_id'])) {
             $id = !empty($item['variation_id']) ? $item['variation_id'] : $item['product_id'];
             /**
              * Set the unique product ID
              */
             $item_query_args['ITEM_ID' . $i] = $id;
             /**
              * Get the product QTY
              */
             $item_query_args['QUANTITY' . $i] = isset($item['qty']) ? absint($item['qty']) : 0;
             /**
              * Get the product total, and deduct the average item discount from it.
              * absint() should always give us a number greater or equal to zero.
              */
             $item_query_args['ITEM_PRICE' . $i] = 0 < $total ? number_format($total, 2, '.', '') : 0;
         }
     }
     $src = $this->generate_iframe_src($order_id, $item_query_args);
     return '<iframe src="' . $src . '" width="1" height="1" frameborder="0"></iframe>';
 }
开发者ID:blacksector,项目名称:woocommerce-ebay-enterprise-affiliates,代码行数:39,代码来源:woocommerce-ebay-enterprise-affiliates.php

示例6: get_coupon_by_user

 public function get_coupon_by_user()
 {
     global $woocommerce;
     DABBA_API_Catch_Request::get()->check_params(array('user_id'));
     $args = array('numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => $_POST['user_id'], 'post_type' => 'shop_order', 'post_status' => 'publish');
     $customer_orders = get_posts($args);
     $coupons_user = array();
     if ($customer_orders) {
         foreach ($customer_orders as $customer_order) {
             $order = new WC_Order($customer_order->ID);
             $couponR = $order->get_used_coupons();
             if ($couponR) {
                 foreach ($couponR as $singleCoupon) {
                     $coupon = new WC_Coupon($singleCoupon);
                     $order_info = array('order_id' => $order->id, "order_date" => $order->order_date, "total" => $order->get_total(), "status" => $order->get_status(), "items" => $order->get_items(), "payment_method" => $order->payment_method, "billing_address" => $order->get_address('billing'), "shipping_address" => $order->get_address('shipping'));
                     $coupons_user[] = array('order' => $order_info, 'coupon' => $coupon);
                 }
             }
         }
     }
     DABBA_API_Output::get()->output(true, 200, '', $coupons_user);
 }
开发者ID:pcuervo,项目名称:dabba,代码行数:22,代码来源:class-dabba_api-webservices.php

示例7: output_impact_radius_order_code

    /**
     * Output the order tracking code for link connector
     *
     * @param WC_Order $order
     *
     * @return string
     */
    public function output_impact_radius_order_code($order)
    {
        if (!$this->impact_radius_src) {
            return;
        }
        $code = '<script src="https://' . $this->impact_radius_src . '"></script>';
        $code .= '<script>/* <![CDATA[ */
    irEvent.setOrderId("' . esc_js($order->get_order_number()) . '");';
        if ($order->get_items()) {
            foreach ($order->get_items() as $item) {
                $_product = $order->get_product_from_item($item);
                $categories = get_the_terms($_product->id, 'product_cat');
                $category = $categories ? $category[0]->name : '';
                $sku = $_product->get_sku() ? $_product->get_sku() : $_product->id;
                $code .= '
    irEvent.addItem("' . esc_js($category) . '", "' . esc_js($sku) . '", "' . esc_js($order->get_item_total($item)) . '", "' . esc_js($item['qty']) . '");';
            }
        }
        $coupons = $order->get_used_coupons();
        $coupon = $coupons ? $coupons[0] : '';
        $code .= '
    irEvent.setPromoCode("' . esc_js($coupon) . '");
    irEvent.fire();
/* ]]> */</script>';
        echo $code;
    }
开发者ID:strikewood,项目名称:woocommerce-affiliate-tracking,代码行数:33,代码来源:class-wc-affiliate-tracking-integration.php

示例8: array

 }
 echo "\nUSER ID : ";
 var_dump($user_id);
 echo "\n";
 if ($user_id instanceof WP_Error) {
     $temp_log_str = "\nUser could not be created. Invalid Email. So order could not be migrated ...\n";
     $log_str .= $temp_log_str;
     echo $temp_log_str;
     continue;
 }
 // Prepare Products array & cart array for the order.
 $downloads = array();
 $cart_details = array();
 $wc_items = $order->get_items();
 // Decide whether any coupon is used for discount or not.
 $wc_coupon = $order->get_used_coupons();
 if (!empty($wc_coupon)) {
     $wc_coupon = new WC_Coupon($wc_coupon[0]);
 } else {
     $wc_coupon = null;
 }
 // Line Items from the WC Order
 foreach ($wc_items as $item) {
     $product = $order->get_product_from_item($item);
     $item['quantity'] = $item['qty'];
     $item['data'] = $product;
     if (!isset($wc_edd_product_map[$product->id]) || empty($wc_edd_product_map[$product->id])) {
         $temp_log_str = "\nEDD Product Not available for this WC Product.\n";
         $log_str .= $temp_log_str;
         echo $temp_log_str;
         $break_loop = true;
开发者ID:kishoresahoo,项目名称:woocommerce-to-easydigitaldownloads,代码行数:31,代码来源:migrate.php

示例9: batchInvoice

 private function batchInvoice()
 {
     $json = file_get_contents('php://input');
     $json = json_decode($json);
     $invoices = array();
     try {
         if (!property_exists($json, 'customers')) {
             throw new GenericException('Invalid JSON request');
         }
         foreach ($json->customers as $customer) {
             if (!property_exists($customer, 'email')) {
                 continue;
             }
             if (email_exists($customer->email)) {
                 $invoice = new Invoice();
                 $invoice->setEmail($customer->email);
                 $orderPosts = get_posts(array('meta_key' => '_billing_email', 'meta_value' => $customer->email, 'post_type' => 'shop_order', 'numberposts' => -1));
                 foreach ($orderPosts as $post) {
                     $wpOrder = new WC_Order($post->ID);
                     if ($wpOrder->order_date > $customer->from && $wpOrder->order_date < $customer->to) {
                         $total = 0.0;
                         $tax = 0.0;
                         $count = 0;
                         $order = new Order();
                         foreach ($wpOrder->get_items('line_item') as $lineItem) {
                             $tax += (double) $lineItem['line_tax'];
                             $total += (double) $lineItem['line_total'] - (double) $lineItem['line_tax'];
                             $count++;
                             if ($lineItem->tax_class) {
                                 $order->setCurrency($lineItem['tax_class']);
                             }
                         }
                         $order->setId($wpOrder->id)->setDate(new \DateTime($wpOrder->order_date))->setItemCount($count)->setTotal($total, $tax);
                         $coupons = $wpOrder->get_used_coupons();
                         if (!empty($coupons)) {
                             $order->setCoupon($coupons[0]);
                         }
                         $invoice->addOrder($order);
                     }
                 }
                 $invoices[] = $invoice;
             }
         }
     } catch (GenericException $e) {
         $this->app['logger']->error($e);
     }
     $presenter = new BatchInvoicePresenter($invoices);
     wp_send_json($presenter->toArray());
 }
开发者ID:andrea-t,项目名称:woocommerce,代码行数:49,代码来源:expressly.php

示例10: fp_rac_adandoncart_admin_display


//.........这里部分代码省略.........
                //Link Clicked
                if (!empty($each_list->link_status)) {
                    $mails_clicked = maybe_unserialize($each_list->link_status);
                    if (in_array($check_all_email_temp->id, (array) $mails_clicked)) {
                        //  echo $check_all_email_temp->template_name;
                        echo ' / Cart Link Clicked';
                        echo '<br>';
                    } else {
                        // echo $check_all_email_temp->template_name;
                        echo ' / Cart Link Not Clicked';
                        echo '<br>';
                    }
                } else {
                    echo ' / Cart Link Not Clicked';
                    echo '<br>';
                }
                //Link Clicked END
            }
            ?>

                    </td>
                    <td data-value="<?php 
            echo $each_list->placed_order;
            ?>
"><?php 
            echo !is_null($each_list->placed_order) ? ' #' . $each_list->placed_order . '' : 'Not Yet';
            ?>
</td>
                    <td>
                        <?php 
            if ($each_list->cart_status == 'RECOVERED') {
                $coupon_code = get_option('abandon_time_of' . $each_list->id);
                $order = new WC_Order($each_list->placed_order);
                $coupons_used = $order->get_used_coupons();
                if (!empty($coupons_used)) {
                    if (in_array($coupon_code, $order->get_used_coupons())) {
                        echo $coupon_code . ' - ';
                        echo 'Succes';
                    } else {
                        echo 'Not Used';
                    }
                } else {
                    echo 'Not Used';
                }
            } else {
                echo 'Not Yet';
            }
            ?>

                    </td>
                    <td><?php 
            echo !empty($each_list->completed) ? 'Completed' : 'Not Yet';
            ?>
</td>
                    <td>
                        <?php 
            if ($each_list->cart_status != 'trash') {
                if (empty($each_list->completed)) {
                    //check if order completed,if completed don't show mail sending button'
                    ?>


                                <a href="#" class="button rac_mail_sending" data-racmoptid="<?php 
                    echo $each_list->id;
                    ?>
" data-currentsate="<?php 
开发者ID:bear12345678,项目名称:keylessoption,代码行数:67,代码来源:recoverabandoncart.php

示例11: array

    /**
     * Google Analytics eCommerce tracking
     *
     * @access public
     * @param mixed $order_id
     * @return void
     */
    function ecommerce_tracking_code($order_id)
    {
        global $woocommerce;
        if ($this->disable_tracking($this->ga_eeT) || current_user_can("manage_options") || get_post_meta($order_id, "_tracked", true) == 1) {
            return;
        }
        $tracking_id = $this->ga_id;
        if (!$tracking_id) {
            return;
        }
        // Doing eCommerce tracking so unhook standard tracking from the footer
        remove_action("wp_footer", array($this, "ee_settings"));
        // Get the order and output tracking code
        $order = new WC_Order($order_id);
        //Get Applied Coupon Codes
        $coupons_list = '';
        if ($order->get_used_coupons()) {
            $coupons_count = count($order->get_used_coupons());
            $i = 1;
            foreach ($order->get_used_coupons() as $coupon) {
                $coupons_list .= $coupon;
                if ($i < $coupons_count) {
                    $coupons_list .= ', ';
                }
                $i++;
            }
        }
        //get domain name if value is set
        if (!empty($this->ga_Dname)) {
            $set_domain_name = esc_js($this->ga_Dname);
        } else {
            $set_domain_name = "auto";
        }
        //add display features
        if ($this->ga_DF) {
            $ga_display_feature_code = 'ga("require", "displayfeatures");';
        } else {
            $ga_display_feature_code = "";
        }
        //add Pageview on order page if user checked Add Standard UA code
        if ($this->ga_ST) {
            $ga_pageview = 'ga("send", "pageview");';
        } else {
            $ga_pageview = "";
        }
        $code = '(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
			(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
			m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
			})(window,document,"script","//www.google-analytics.com/analytics.js","ga");
                        
			ga("create", "' . esc_js($tracking_id) . '", "' . $set_domain_name . '");
                        ' . $ga_display_feature_code . '
			ga("require", "ec", "ec.js");
                        ' . $ga_pageview . '
                        ';
        // Order items
        if ($order->get_items()) {
            foreach ($order->get_items() as $item) {
                $_product = $order->get_product_from_item($item);
                if (isset($_product->variation_data)) {
                    $categories = esc_js(woocommerce_get_formatted_variation($_product->variation_data, true));
                } else {
                    $out = array();
                    $categories = get_the_terms($_product->id, "product_cat");
                    if ($categories) {
                        foreach ($categories as $category) {
                            $out[] = $category->name;
                        }
                    }
                    $categories = esc_js(join(",", $out));
                }
                //orderpage Prod json
                $orderpage_prod_Array[get_permalink($_product->id)] = array("tvc_id" => esc_html($_product->id), "tvc_i" => esc_js($_product->get_sku() ? $_product->get_sku() : $_product->id), "tvc_n" => esc_js($item["name"]), "tvc_p" => esc_js($order->get_item_total($item)), "tvc_c" => $categories, "tvc_q" => esc_js($item["qty"]));
            }
            //make json for prod meta data on order page
            $this->wc_version_compare("tvc_oc=" . json_encode($orderpage_prod_Array) . ";");
        }
        //get shipping cost based on version >2.1 get_total_shipping() < get_shipping
        if (version_compare($woocommerce->version, "2.1", ">=")) {
            $tvc_sc = $order->get_total_shipping();
        } else {
            $tvc_sc = $order->get_shipping();
        }
        //orderpage transcation data json
        $orderpage_trans_Array = array("id" => esc_js($order->get_order_number()), "affiliation" => esc_js(get_bloginfo('name')), "revenue" => esc_js($order->get_total()), "tax" => esc_js($order->get_total_tax()), "shipping" => esc_js($tvc_sc), "coupon" => $coupons_list);
        //make json for trans data on order page
        $this->wc_version_compare("tvc_td=" . json_encode($orderpage_trans_Array) . ";");
        $code .= '
                //set local currencies
            ga("set", "&cu", tvc_lc);  
            for(var t_item in tvc_oc){
                ga("ec:addProduct", { 
                    "id": tvc_oc[t_item].tvc_i,
//.........这里部分代码省略.........
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:101,代码来源:class-wc-enhanced-ecommerce-google-analytics-integration.php

示例12:

 function coupons_used($order_id)
 {
     $order = new WC_Order($order_id);
     $email = get_post_meta($order_id, 'gift_receiver_email', true);
     /** this validation is not required
         * 
         * 
            if ( empty( $email ) || ! is_email( $email ) ) {
                    $email = $order->billing_email;
            }
         * 
         * 
         * **/
     if ($order->get_used_coupons()) {
         $this->update_coupons($order->get_used_coupons(), $email, '', 'remove');
     }
 }
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:17,代码来源:woocommerce-smart-coupons.php

示例13: generate_attendee_csv

function generate_attendee_csv($export_event_id)
{
    $all_attendees = TribeEventsTickets::get_event_attendees($export_event_id);
    $export_attendee_list = array();
    $counter = 0;
    $attendee_counter = 1;
    $old_order_id = 0;
    foreach ($all_attendees as $attendee) {
        $order_id = $attendee['order_id'];
        $order = new WC_Order($order_id);
        $order_meta = get_post_meta($order_id);
        $_product_id = $attendee['product_id'];
        // Purchaser Name
        $purchaser_name = $order_meta['_billing_first_name'][0] . ' ' . $order_meta['_billing_last_name'][0];
        // Company
        $company = $order_meta['_billing_company'][0];
        // Address
        $address1 = $order_meta['_billing_address_1'][0];
        $address2 = $order_meta['_billing_address_2'][0];
        $address = $address1 . ' ' . $address2;
        // City, State & Zip
        $city = $order_meta['_billing_city'][0];
        $state = $order_meta['_billing_state'][0];
        $zip = $order_meta['_billing_postcode'][0];
        // Email
        $purchaser_email = $order_meta['_billing_email'][0];
        // Amount paid
        $amt_paid = $order->get_formatted_order_total();
        $amt_paid = html_entity_decode(strip_tags($amt_paid), ENT_QUOTES, 'utf-8');
        // Reset the counter after each order
        if ($old_order_id == 0) {
            $old_order_id = $order_id;
        } else {
            if ($order_id != $old_order_id) {
                $attendee_counter = 1;
                $old_order_id = $order_id;
            }
        }
        // Attendee Name, Attendee Email, Job Title, Dietary Restrictions & Phone
        //$attendee_name                 = get_post_meta( $order_id, 'attendee_name_'.$_product_id.'_'.$attendee_counter, true);
        $attendee_first_name = get_post_meta($order_id, 'attendee_first_name_' . $_product_id . '_' . $attendee_counter, true);
        if (empty($attendee_first_name)) {
            $attendee_first_name = get_post_meta($order_id, 'attendee_name_' . $_product_id . '_' . $attendee_counter, true);
        }
        $attendee_last_name = get_post_meta($order_id, 'attendee_last_name_' . $_product_id . '_' . $attendee_counter, true);
        $attendee_email = get_post_meta($order_id, 'attendee_email_' . $_product_id . '_' . $attendee_counter, true);
        $attendee_job_title = get_post_meta($order_id, 'attendee_job_title_' . $_product_id . '_' . $attendee_counter, true);
        $attendee_dietary_restrictions = get_post_meta($order_id, 'attendee_dietary_restrictions_' . $_product_id . '_' . $attendee_counter, true);
        $phone = $order_meta['_billing_phone'][0];
        $discount = round($order_meta['_cart_discount'][0], 2);
        $coupons = $order->get_used_coupons();
        $coupon = $coupons[0];
        if (!$coupon) {
            $coupon = $discount = "";
        } else {
            $discount = "\$" . $discount;
        }
        $export_attendee_list[$counter] = array($purchaser_name, $phone, $company, $address, $city, $state, $zip, $purchaser_email, $amt_paid, $attendee_first_name, $attendee_last_name, $attendee_email, $attendee_company, $attendee_job_title, $attendee_dietary_restrictions, $attendee_cell_phone, $attendee_work_phone, $coupon, $discount);
        $counter++;
        $attendee_counter++;
    }
    $event = get_post($export_event_id);
    if (!empty($export_attendee_list)) {
        $charset = get_option('blog_charset');
        $start_date = strtotime(get_post_meta($event, '_EventStartDate', true));
        $filename = $event->post_name;
        // output headers so that the file is downloaded rather than displayed
        header("Content-Type: text/csv; charset={$charset}");
        header("Content-Disposition: attachment; filename={$filename}-attendees.csv");
        // create a file pointer connected to the output stream
        $output = fopen('php://output', 'w');
        fputcsv($output, array('Purchaser Name', 'Purchaser Phone', 'Purchaser Company', 'Address', 'City', 'State', 'Zip', 'Purchaser Email', 'Amount Paid', 'Attendee First Name', 'Attendee Last Name', 'Attendee Email', 'Attendee Company', 'Job Title', 'Dietary Restrictions', 'Cell Phone', 'Work Phone', 'Coupon Code', 'Coupon Amount'));
        foreach ($export_attendee_list as $item) {
            fputcsv($output, $item);
        }
        fclose($output);
        exit;
    }
}
开发者ID:georgi-kovachev,项目名称:mapClass,代码行数:79,代码来源:attendees-export.php

示例14: order_has_coupon

/**
 * Check if an order has a coupon
 *
 * @param WC_Order $order
 * @param string $coupon_name
 * @return boolean
 */
function order_has_coupon(WC_Order $order, $coupon_name)
{
    if (!$order->get_used_coupons()) {
        return 0;
    }
    if (in_array($coupon_name, $order->get_used_coupons())) {
        return 1;
    }
}
开发者ID:pcuervo,项目名称:dabba,代码行数:16,代码来源:functions.php

示例15: woo_email_order_coupons

/**
 * WooCommerce Extra Feature
 * --------------------------
 *
 * Send an email each time an order with coupon(s) is completed
 * The email contains coupon(s) used during checkout process
 *
 */
function woo_email_order_coupons($order_id)
{
    $order = new WC_Order($order_id);
    if ($order->get_used_coupons()) {
        $to = 'ben@wodmagazine.com.au';
        $subject = 'New Coupon Order Completed';
        $headers = 'From: WOD Magazine <info@wodmagazine.com.au>' . "\r\n";
        $message = 'A new order has been completed.\\n';
        $message .= 'Order ID: ' . $order_id . '\\n';
        $message .= 'Coupons used:\\n';
        foreach ($order->get_used_coupons() as $coupon) {
            $message .= $coupon . '\\n';
        }
        @wp_mail($to, $subject, $message, $headers);
    }
}
开发者ID:benquinney,项目名称:WOD-Magazine-Custom-Braxton-theme,代码行数:24,代码来源:functions.php


注:本文中的WC_Order::get_used_coupons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。