• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_clean函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_clean函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_clean函数的具体用法?PHP wc_clean怎么用?PHP wc_clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: handle_api_requests

 /**
  * API request - Trigger any API requests.
  *
  * @since   2.0
  * @version 2.4
  */
 public function handle_api_requests()
 {
     global $wp;
     if (!empty($_GET['wc-api'])) {
         $wp->query_vars['wc-api'] = $_GET['wc-api'];
     }
     // wc-api endpoint requests.
     if (!empty($wp->query_vars['wc-api'])) {
         // Buffer, we won't want any output here.
         ob_start();
         // No cache headers.
         nocache_headers();
         // Clean the API request.
         $api_request = strtolower(wc_clean($wp->query_vars['wc-api']));
         // Trigger generic action before request hook.
         do_action('woocommerce_api_request', $api_request);
         // Is there actually something hooked into this API request? If not trigger 400 - Bad request.
         status_header(has_action('woocommerce_api_' . $api_request) ? 200 : 400);
         // Trigger an action which plugins can hook into to fulfill the request.
         do_action('woocommerce_api_' . $api_request);
         // Done, clear buffer and exit.
         ob_end_clean();
         die('-1');
     }
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:31,代码来源:class-wc-api.php


示例2: output

 /**
  * Output the calendar view
  */
 public function output()
 {
     wp_enqueue_script('chosen');
     $product_filter = isset($_REQUEST['filter_bookings']) ? absint($_REQUEST['filter_bookings']) : '';
     $view = isset($_REQUEST['view']) && $_REQUEST['view'] == 'day' ? 'day' : 'month';
     if ($view == 'day') {
         $day = isset($_REQUEST['calendar_day']) ? wc_clean($_REQUEST['calendar_day']) : date('Y-m-d');
         $this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime('midnight', strtotime($day)), strtotime('midnight +1 day', strtotime($day)), $product_filter);
     } else {
         $month = isset($_REQUEST['calendar_month']) ? absint($_REQUEST['calendar_month']) : date('n');
         $year = isset($_REQUEST['calendar_year']) ? absint($_REQUEST['calendar_year']) : date('Y');
         if ($year < date('Y') - 10 || $year > 2100) {
             $year = date('Y');
         }
         if ($month > 12) {
             $month = 1;
             $year++;
         }
         if ($month < 1) {
             $month = 1;
             $year--;
         }
         $start_week = (int) date('W', strtotime("first day of {$year}-{$month}"));
         $end_week = (int) date('W', strtotime("last day of {$year}-{$month}"));
         if ($end_week == 1) {
             $end_week = 53;
         }
         $this->bookings = WC_Bookings_Controller::get_bookings_in_date_range(strtotime($year . 'W' . str_pad($start_week, 2, '0', STR_PAD_LEFT)), strtotime($year . 'W' . str_pad($end_week + 1, 2, '0', STR_PAD_LEFT)), $product_filter);
     }
     include 'views/html-calendar-' . $view . '.php';
     wc_enqueue_js('$( "select#calendar-bookings-filter" ).chosen();');
 }
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:35,代码来源:class-wc-bookings-calendar.php


示例3: save_meta

 /**
  * Get the new payment data from POST and check the new payment method supports
  * the new admin change hook.
  *
  * @since 2.0
  * @param $subscription WC_Subscription
  */
 public static function save_meta($subscription)
 {
     if (empty($_POST['_wcsnonce']) || !wp_verify_nonce($_POST['_wcsnonce'], 'wcs_change_payment_method_admin')) {
         return;
     }
     $payment_gateways = WC()->payment_gateways->payment_gateways();
     $payment_method = isset($_POST['_payment_method']) ? wc_clean($_POST['_payment_method']) : '';
     $payment_method_meta = apply_filters('woocommerce_subscription_payment_meta', array(), $subscription);
     $payment_method_meta = !empty($payment_method_meta[$payment_method]) ? $payment_method_meta[$payment_method] : array();
     $valid_payment_methods = self::get_valid_payment_methods($subscription);
     if (!isset($valid_payment_methods[$payment_method])) {
         throw new Exception(__('Please choose a valid payment gateway to change to.', 'woocommerce-subscriptions'));
     }
     if (!empty($payment_method_meta)) {
         foreach ($payment_method_meta as $meta_table => &$meta) {
             if (!is_array($meta)) {
                 continue;
             }
             foreach ($meta as $meta_key => &$meta_data) {
                 $meta_data['value'] = isset($_POST['_payment_method_meta'][$meta_table][$meta_key]) ? $_POST['_payment_method_meta'][$meta_table][$meta_key] : '';
             }
         }
     }
     $payment_gateway = 'manual' != $payment_method ? $payment_gateways[$payment_method] : '';
     if (!$subscription->is_manual() && property_exists($subscription->payment_gateway, 'id') && ('' == $payment_gateway || $subscription->payment_gateway->id != $payment_gateway->id)) {
         // Before updating to a new payment gateway make sure the subscription status is updated with the current gateway
         $gateway_status = apply_filters('wcs_gateway_status_payment_changed', 'cancelled', $subscription, $payment_gateway);
         WC_Subscriptions_Payment_Gateways::trigger_gateway_status_updated_hook($subscription, $gateway_status);
     }
     $subscription->set_payment_method($payment_gateway, $payment_method_meta);
 }
开发者ID:slavic18,项目名称:cats,代码行数:38,代码来源:class-wcs-change-payment-method-admin.php


示例4: check_response

 /**
  * Check Response for PDT
  */
 public function check_response()
 {
     if (empty($_REQUEST['cm']) || empty($_REQUEST['tx']) || empty($_REQUEST['st'])) {
         return;
     }
     $order_id = wc_clean(stripslashes($_REQUEST['cm']));
     $status = wc_clean(strtolower(stripslashes($_REQUEST['st'])));
     $amount = wc_clean(stripslashes($_REQUEST['amt']));
     $transaction = wc_clean(stripslashes($_REQUEST['tx']));
     if (!($order = $this->get_paypal_order($order_id)) || !$order->has_status('pending')) {
         return false;
     }
     if ($this->validate_transaction($transaction) && 'completed' === $status) {
         if ($order->get_total() != $amount) {
             WC_Gateway_Paypal::log('Payment error: Amounts do not match (amt ' . $amount . ')');
             $this->payment_on_hold($order, sprintf(__('Validation error: PayPal amounts do not match (amt %s).', 'woocommerce'), $amount));
         } else {
             $this->payment_complete($order, $transaction, __('PDT payment completed', 'woocommerce'));
             if (!empty($_REQUEST['mc_fee'])) {
                 // log paypal transaction fee
                 update_post_meta($order->id, 'PayPal Transaction Fee', wc_clean($_REQUEST['mc_fee']));
             }
         }
     }
 }
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:28,代码来源:class-wc-gateway-paypal-pdt-handler.php


示例5: calculate_shipping

 /**
  * Calculate shipping for the cart
  */
 public static function calculate_shipping()
 {
     try {
         WC()->shipping->reset_shipping();
         $country = wc_clean($_POST['calc_shipping_country']);
         $state = wc_clean(isset($_POST['calc_shipping_state']) ? $_POST['calc_shipping_state'] : '');
         $postcode = apply_filters('woocommerce_shipping_calculator_enable_postcode', true) ? wc_clean($_POST['calc_shipping_postcode']) : '';
         $city = apply_filters('woocommerce_shipping_calculator_enable_city', false) ? wc_clean($_POST['calc_shipping_city']) : '';
         if ($postcode && !WC_Validation::is_postcode($postcode, $country)) {
             throw new Exception(__('Please enter a valid postcode/ZIP.', 'woocommerce'));
         } elseif ($postcode) {
             $postcode = wc_format_postcode($postcode, $country);
         }
         if ($country) {
             WC()->customer->set_location($country, $state, $postcode, $city);
             WC()->customer->set_shipping_location($country, $state, $postcode, $city);
         } else {
             WC()->customer->set_to_base();
             WC()->customer->set_shipping_to_base();
         }
         WC()->customer->calculated_shipping(true);
         wc_add_notice(__('Shipping costs updated.', 'woocommerce'), 'notice');
         do_action('woocommerce_calculated_shipping');
     } catch (Exception $e) {
         if (!empty($e)) {
             wc_add_notice($e->getMessage(), 'error');
         }
     }
 }
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:32,代码来源:class-wc-shortcode-cart.php


示例6: __construct

 /**
  * Constructor.
  *
  * @return \YITH_WCStripe_Gateway
  * @since 1.0.0
  */
 public function __construct()
 {
     $this->id = YITH_WCStripe::$gateway_id;
     $this->has_fields = true;
     $this->method_title = apply_filters('yith_stripe_method_title', __('Stripe', 'yith-stripe'));
     $this->method_description = apply_filters('yith_stripe_method_description', __('Take payments via Stripe - uses stripe.js to create card tokens and the Stripe SDK. Requires SSL when sandbox is disabled.', 'yith-stripe'));
     $this->supports = array('products');
     $this->instance = preg_replace('/http(s)?:\\/\\//', '', site_url());
     // Load the settings.
     $this->init_form_fields();
     $this->init_settings();
     // Define user set variables
     $this->title = $this->get_option('title');
     $this->description = $this->get_option('description');
     $this->env = $this->get_option('enabled_test_mode') == 'yes' ? 'test' : 'live';
     $this->private_key = $this->get_option($this->env . '_secrect_key');
     $this->public_key = $this->get_option($this->env . '_publishable_key');
     $this->modal_image = $this->get_option('modal_image');
     $this->mode = 'hosted';
     // post data
     $this->token = isset($_POST['stripe_token']) ? wc_clean($_POST['stripe_token']) : '';
     // save
     add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
     // others
     add_action('admin_notices', array($this, 'admin_notices'));
     add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page'));
     add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'return_handler'));
 }
开发者ID:yarwalker,项目名称:ecobyt,代码行数:34,代码来源:class-yith-stripe-gateway.php


示例7: save_meta

 /**
  * Get the new payment data from POST and check the new payment method supports
  * the new admin change hook.
  *
  * @since 2.0
  * @param $subscription WC_Subscription
  */
 public static function save_meta($subscription)
 {
     if (empty($_POST['_wcsnonce']) || !wp_verify_nonce($_POST['_wcsnonce'], 'wcs_change_payment_method_admin')) {
         return;
     }
     $payment_gateways = WC()->payment_gateways->payment_gateways();
     $payment_method = isset($_POST['_payment_method']) ? wc_clean($_POST['_payment_method']) : '';
     $payment_method_meta = apply_filters('woocommerce_subscription_payment_meta', array(), $subscription);
     $payment_method_meta = !empty($payment_method_meta[$payment_method]) ? $payment_method_meta[$payment_method] : array();
     $valid_payment_methods = self::get_valid_payment_methods($subscription);
     if (!isset($valid_payment_methods[$payment_method])) {
         throw new Exception(__('Please choose a valid payment gateway to change to.', 'woocommerce-subscriptions'));
     }
     if (!empty($payment_method_meta)) {
         foreach ($payment_method_meta as $meta_table => &$meta) {
             if (!is_array($meta)) {
                 continue;
             }
             foreach ($meta as $meta_key => &$meta_data) {
                 $meta_data['value'] = isset($_POST['_payment_method_meta'][$meta_table][$meta_key]) ? $_POST['_payment_method_meta'][$meta_table][$meta_key] : '';
             }
         }
     }
     $payment_gateway = 'manual' != $payment_method ? $payment_gateways[$payment_method] : '';
     $subscription->set_payment_method($payment_gateway, $payment_method_meta);
 }
开发者ID:ltdat287,项目名称:id.nhomdichvu,代码行数:33,代码来源:class-wcs-change-payment-method-admin.php


示例8: gzd_json_search_delivery_time

 public static function gzd_json_search_delivery_time()
 {
     ob_start();
     check_ajax_referer('search-products', 'security');
     $term = (string) wc_clean(stripslashes($_GET['term']));
     $terms = array();
     if (empty($term)) {
         die;
     }
     $args = array('hide_empty' => false);
     if (is_numeric($term)) {
         $args['include'] = array(absint($term));
     } else {
         $args['name__like'] = (string) $term;
     }
     $query = get_terms('product_delivery_time', $args);
     if (!empty($query)) {
         foreach ($query as $term) {
             $terms[$term->term_id] = rawurldecode($term->name);
         }
     } else {
         $terms[rawurldecode($term)] = rawurldecode(sprintf(__("%s [new]", "woocommerce-germanized"), $term));
     }
     wp_send_json($terms);
 }
开发者ID:radscheit,项目名称:unicorn,代码行数:25,代码来源:class-wc-gzd-ajax.php


示例9: sundaysea_update_cart2

 function sundaysea_update_cart2($cart_totals)
 {
     // Add Discount
     if (!empty($_POST['coupon_code'])) {
         WC()->cart->add_discount(sanitize_text_field($_POST['coupon_code']));
     } elseif (isset($_GET['remove_coupon'])) {
         WC()->cart->remove_coupon(wc_clean($_GET['remove_coupon']));
     }
     global $woocommerce;
     if (sizeof($woocommerce->cart->get_cart()) > 0) {
         foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) {
             // Skip product if no updated quantity was posted
             if (!isset($cart_totals[$cart_item_key]['qty'])) {
                 continue;
             }
             // Sanitize
             $quantity = apply_filters('woocommerce_stock_amount_cart_item', apply_filters('woocommerce_stock_amount', preg_replace("/[^0-9\\.]/", "", $cart_totals[$cart_item_key]['qty'])), $cart_item_key);
             if ("" === $quantity || $quantity == $values['quantity']) {
                 continue;
             }
             // Update cart validation
             $passed_validation = apply_filters('woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity);
             $_product = $values['data'];
             // is_sold_individually
             if ($_product->is_sold_individually() && $quantity > 1) {
                 $woocommerce->add_error(sprintf(__('You can only have 1 %s in your cart.', 'woocommerce'), $_product->get_title()));
                 $passed_validation = false;
             }
             if ($passed_validation) {
                 $woocommerce->cart->set_quantity($cart_item_key, $quantity, false);
             }
         }
         $woocommerce->cart->calculate_totals();
     }
 }
开发者ID:vphat28,项目名称:horizontal-slide-out-cart-for-woocommerce,代码行数:35,代码来源:woocommerce-slide-out-cart.php


示例10: download_product

 /**
  * Check if we need to download a file and check validity.
  */
 public static function download_product()
 {
     $product_id = absint($_GET['download_file']);
     $product = wc_get_product($product_id);
     $data_store = WC_Data_Store::load('customer-download');
     if (!$product || !isset($_GET['key'], $_GET['order'])) {
         self::download_error(__('Invalid download link.', 'woocommerce'));
     }
     $download_ids = $data_store->get_downloads(array('user_email' => sanitize_email(str_replace(' ', '+', $_GET['email'])), 'order_key' => wc_clean($_GET['order']), 'product_id' => $product_id, 'download_id' => wc_clean(preg_replace('/\\s+/', ' ', $_GET['key'])), 'orderby' => 'downloads_remaining', 'order' => 'DESC', 'limit' => 1, 'return' => 'ids'));
     if (empty($download_ids)) {
         self::download_error(__('Invalid download link.', 'woocommerce'));
     }
     $download = new WC_Customer_Download(current($download_ids));
     self::check_order_is_valid($download);
     self::check_downloads_remaining($download);
     self::check_download_expiry($download);
     self::check_download_login_required($download);
     do_action('woocommerce_download_product', $download->get_user_email(), $download->get_order_key(), $download->get_product_id(), $download->get_user_id(), $download->get_download_id(), $download->get_order_id());
     $count = $download->get_download_count();
     $remaining = $download->get_downloads_remaining();
     $download->set_download_count($count++);
     $download->set_downloads_remaining($remaining--);
     $download->save();
     self::download($product->get_file_download_path($download->get_download_id()), $download->get_product_id());
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:28,代码来源:class-wc-download-handler.php


示例11: product_search_sku

function product_search_sku($where)
{
    global $pagenow, $wpdb, $wp;
    //VAR_DUMP(http_build_query(array('post_type' => array('product','boobs'))));die();
    $type = array('product', 'jam');
    //var_dump(in_array('product', $wp->query_vars['post_type']));
    if (is_admin() && 'edit.php' != $pagenow || !is_search() || !isset($wp->query_vars['s']) || isset($wp->query_vars['post_type']) && 'product' != $wp->query_vars['post_type'] || isset($wp->query_vars['post_type']) && is_array($wp->query_vars['post_type']) && !in_array('product', $wp->query_vars['post_type'])) {
        return $where;
    }
    $search_ids = array();
    $terms = explode(',', $wp->query_vars['s']);
    foreach ($terms as $term) {
        //Include the search by id if admin area.
        if (is_admin() && is_numeric($term)) {
            $search_ids[] = $term;
        }
        // search for variations with a matching sku and return the parent.
        $sku_to_parent_id = $wpdb->get_col($wpdb->prepare("SELECT p.post_parent as post_id FROM {$wpdb->posts} as p join {$wpdb->postmeta} pm on p.ID = pm.post_id and pm.meta_key='_sku' and pm.meta_value LIKE '%%%s%%' where p.post_parent <> 0 group by p.post_parent", wc_clean($term)));
        //Search for a regular product that matches the sku.
        $sku_to_id = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='_sku' AND meta_value LIKE '%%%s%%';", wc_clean($term)));
        $search_ids = array_merge($search_ids, $sku_to_id, $sku_to_parent_id);
    }
    $search_ids = array_filter(array_map('absint', $search_ids));
    if (sizeof($search_ids) > 0) {
        $where = str_replace(')))', ") OR ({$wpdb->posts}.ID IN (" . implode(',', $search_ids) . "))))", $where);
    }
    remove_filters_for_anonymous_class('posts_search', 'WC_Admin_Post_Types', 'product_search', 10);
    return $where;
}
开发者ID:TakenCdosG,项目名称:chefs,代码行数:29,代码来源:wc-searchbysku-widget-compat.php


示例12: gzd_revocation

 /**
  * Checks revocation form and sends Email to customer and Admin
  */
 public static function gzd_revocation()
 {
     check_ajax_referer('woocommerce-revocation', 'security');
     wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-revocation');
     $data = array();
     $fields = WC_GZD_Revocation::get_fields();
     if (!empty($fields)) {
         foreach ($fields as $key => $field) {
             if ('sep' !== $key) {
                 if ($key == 'address_mail') {
                     if (!is_email($_POST[$key])) {
                         wc_add_notice('<strong>' . $field['label'] . '</strong> ' . _x('is not a valid email address.', 'revocation-form', 'woocommerce-germanized'), 'error');
                     }
                 } elseif ($key == 'address_postal') {
                     if (!WC_Validation::is_postcode($_POST[$key], $_POST['address_country']) || empty($_POST[$key])) {
                         wc_add_notice(_x('Please enter a valid postcode/ZIP', 'revocation-form', 'woocommerce-germanized'), 'error');
                     }
                 } else {
                     if (isset($field['required']) && empty($_POST[$key])) {
                         wc_add_notice('<strong>' . $field['label'] . '</strong> ' . _x('is not valid.', 'revocation-form', 'woocommerce-germanized'), 'error');
                     }
                 }
                 if (!empty($_POST[$key])) {
                     if ($field['type'] == 'country') {
                         $countries = WC()->countries->get_countries();
                         $country = wc_clean($_POST[$key]);
                         $data[$key] = isset($countries[$country]) ? $countries[$country] : '';
                     } else {
                         $data[$key] = wc_clean($_POST[$key]);
                     }
                 }
             }
         }
     }
     $error = false;
     if (wc_notice_count('error') == 0) {
         wc_add_notice(_x('Thank you. We have received your Revocation Request. You will receive a conformation email within a few minutes.', 'revocation-form', 'woocommerce-germanized'), 'success');
         // Send Mail
         if ($mail = WC_germanized()->emails->get_email_instance_by_id('customer_revocation')) {
             $mail->trigger($data);
             // Send to Admin
             $data['mail'] = get_bloginfo('admin_email');
             $mail->trigger($data);
         }
     } else {
         $error = true;
     }
     ob_start();
     wc_print_notices();
     $messages = ob_get_clean();
     if ($error) {
         echo '<!--WC_START-->' . json_encode(array('result' => 'failure', 'messages' => isset($messages) ? $messages : '')) . '<!--WC_END-->';
     } else {
         if (is_ajax()) {
             echo '<!--WC_START-->' . json_encode(array('result' => 'success', 'messages' => isset($messages) ? $messages : '')) . '<!--WC_END-->';
         }
     }
     exit;
 }
开发者ID:ronzeiller,项目名称:woocommerce-germanized,代码行数:62,代码来源:class-wc-gzd-ajax.php


示例13: edit_coupon

 /**
  * Edit a coupon.
  * @param int   $id
  * @param array $data
  */
 public static function edit_coupon($id, $data)
 {
     if (isset($data['billing_countries'])) {
         update_post_meta($id, 'billing_countries', wc_clean($data['billing_countries']));
     }
     if (isset($data['shipping_countries'])) {
         update_post_meta($id, 'shipping_countries', wc_clean($data['shipping_countries']));
     }
 }
开发者ID:axisthemes,项目名称:wc-coupons-by-country,代码行数:14,代码来源:class-wc-api-coupon-usage-restrictions.php


示例14: add_method

 /**
  * Add shipping method to zone
  */
 public static function add_method($zone)
 {
     if (!empty($_GET['add_method']) && !empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'woocommerce_add_method')) {
         $type = wc_clean($_GET['method_type']);
         if ($type && ($method_id = $zone->add_shipping_method($type))) {
             echo '<div class="updated fade"><p>' . sprintf(__('Shipping method successfully created. <a href="%s">View method.</a>', SHIPPING_ZONES_TEXTDOMAIN), esc_url(add_query_arg('method', $method_id, add_query_arg('zone', $zone->zone_id, admin_url('admin.php?page=shipping_zones'))))) . '</p></div>';
         } else {
             echo '<div class="error"><p>' . __('Invalid shipping method', SHIPPING_ZONES_TEXTDOMAIN) . '</p></div>';
         }
     }
 }
开发者ID:BennyHudson,项目名称:eaton,代码行数:14,代码来源:class-wc-shipping-zone-admin.php


示例15: save_customer_meta_fields

 /**
  * Save Dolibarr ID field on edit user pages
  *
  * @param mixed $user_id User ID of the user being saved
  *
  * @return void
  */
 public function save_customer_meta_fields($user_id)
 {
     $save_fields = $this->get_customer_meta_fields();
     foreach ($save_fields as $fieldset) {
         foreach ($fieldset['fields'] as $key => $field) {
             if (isset($_POST[$key])) {
                 update_user_meta($user_id, $key, wc_clean($_POST[$key]));
             }
         }
     }
 }
开发者ID:gpcsolutions,项目名称:doliwoo,代码行数:18,代码来源:class-wc-params.php


示例16: process_payment

 /**
  * Process payment
  *
  * @param int $order_id
  */
 public function process_payment($order_id)
 {
     if (!$this->order_contains_subscription($order_id) && !wcs_is_subscription($order_id)) {
         return parent::process_payment($order_id);
     }
     $amazon_billing_agreement_id = isset($_POST['amazon_billing_agreement_id']) ? wc_clean($_POST['amazon_billing_agreement_id']) : '';
     try {
         if (!$amazon_billing_agreement_id) {
             throw new Exception(__('An Amazon payment method was not chosen.', 'woocommerce-gateway-amazon-payments-advanced'));
         }
         $order = new WC_Order($order_id);
         $order_total = $order->get_total();
         $this->log(__FUNCTION__, "Info: Beginning processing of payment for (subscription) order {$order_id} for the amount of {$order_total} {$order->get_order_currency()}.");
         // Set the Billing Agreement Details
         $this->set_billing_agreement_details($order, $amazon_billing_agreement_id);
         // Confirm the Billing Agreement
         $this->confirm_billing_agreement($order_id, $amazon_billing_agreement_id);
         // Get the Billing Agreement Details, with FULL address (now that we've confirmed)
         $result = $this->get_billing_agreement_details($order_id, $amazon_billing_agreement_id);
         // Store the subscription destination
         $this->store_subscription_destination($order_id, $result);
         // Store Billing Agreement ID on the order and it's subscriptions
         $result = update_post_meta($order_id, 'amazon_billing_agreement_id', $amazon_billing_agreement_id);
         if ($result) {
             $this->log(__FUNCTION__, "Info: Successfully stored billing agreement in meta for order {$order_id}.");
         } else {
             $this->log(__FUNCTION__, "Error: Failed to store billing agreement in meta for order {$order_id}.");
         }
         $subscriptions = wcs_get_subscriptions_for_order($order_id);
         foreach ($subscriptions as $subscription) {
             $result = update_post_meta($subscription->id, 'amazon_billing_agreement_id', $amazon_billing_agreement_id);
             if ($result) {
                 $this->log(__FUNCTION__, "Info: Successfully stored billing agreement in meta for subscription {$subscription->id} (parent order {$order_id}).");
             } else {
                 $this->log(__FUNCTION__, "Error: Failed to store billing agreement in meta for subscription {$subscription->id} (parent order {$order_id}).");
             }
         }
         // Authorize/Capture initial payment, if initial payment required
         if ($order_total > 0) {
             return $this->authorize_payment($order, $amazon_billing_agreement_id);
         }
         // No payment needed now, free trial or coupon used - mark order as complete
         $order->payment_complete();
         $this->log(__FUNCTION__, "Info: Zero-total initial payment for (subscription) order {$order_id}. Payment marked as complete.");
         // Remove items from cart
         WC()->cart->empty_cart();
         // Return thank you page redirect
         return array('result' => 'success', 'redirect' => $this->get_return_url($order));
     } catch (Exception $e) {
         $this->log(__FUNCTION__, "Error: Exception encountered: {$e->getMessage()}");
         wc_add_notice(sprintf(__('Error: %s', 'woocommerce-gateway-amazon-payments-advanced'), $e->getMessage()), 'error');
         return;
     }
 }
开发者ID:lilweirdward,项目名称:blofishwordpress,代码行数:59,代码来源:class-wc-gateway-amazon-payments-advanced-subscriptions.php


示例17: json_search_customer_name

 public static function json_search_customer_name($query)
 {
     global $wpdb;
     $term = wc_clean(stripslashes($_GET['term']));
     if (method_exists($wpdb, 'esc_like')) {
         $term = $wpdb->esc_like($term);
     } else {
         $term = like_escape($term);
     }
     $query->query_from .= " INNER JOIN {$wpdb->usermeta} AS user_name ON {$wpdb->users}.ID = user_name.user_id AND ( user_name.meta_key = 'first_name' OR user_name.meta_key = 'last_name' ) ";
     $query->query_where .= $wpdb->prepare(" OR user_name.meta_value LIKE %s ", '%' . $term . '%');
 }
开发者ID:hernanimattos,项目名称:LearnPress,代码行数:12,代码来源:class-lp-admin-ajax.php


示例18: tapfiliate

function tapfiliate()
{
    global $post;
    $postName = $post ? $post->post_name : null;
    $tap_account_id = get_option('tap_account_id');
    $integrate_for = get_option('integrate_for');
    $thank_you_page = get_option('thank_you_page');
    $query_parameter_transaction_id = get_option('query_parameter_transaction_id');
    $query_parameter_transaction_amount = get_option('query_parameter_transaction_amount');
    ?>
<script src="//tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  window['TapfiliateObject'] = i = 'tap';
  window[i] = window[i] || function () {
      (window[i].q = window[i].q || []).push(arguments);
  };

  tap('create', '<?php 
    echo $tap_account_id;
    ?>
');
  <?php 
    if ($integrate_for == 'wp') {
        if ($postName == $thank_you_page) {
            $cid = isset($_GET[$query_parameter_transaction_id]) && !empty($_GET[$query_parameter_transaction_id]) ? "'{$_GET[$query_parameter_transaction_id]}'" : 'null';
            $cam = isset($_GET[$query_parameter_transaction_amount]) && !empty($_GET[$query_parameter_transaction_amount]) ? $_GET[$query_parameter_transaction_amount] : 'null';
            echo "tap('conversion', {$cid}, {$cam});";
        } else {
            echo "tap('detectClick');";
        }
    } elseif ($integrate_for == 'wc') {
        if (function_exists("is_order_received_page") && is_order_received_page()) {
            if (isset($GLOBALS['order-received'])) {
                $order_id = apply_filters('woocommerce_thankyou_order_id', absint($GLOBALS['order-received']));
                $order_key = apply_filters('woocommerce_thankyou_order_key', empty($_GET['key']) ? '' : wc_clean($_GET['key']));
                if ($order_id > 0) {
                    $order = new WC_Order($order_id);
                    if ($order->order_key != $order_key) {
                        unset($order);
                    }
                }
                echo "tap('conversion', '{$order->id}', {$order->get_total()});";
            }
        } else {
            echo "tap('detectClick');";
        }
    }
    ?>
</script>
<?php 
}
开发者ID:ErikTVF,项目名称:Shopping-Cart-Integrations,代码行数:51,代码来源:tapfiliate.php


示例19: download_product

 /**
  * Check if we need to download a file and check validity.
  */
 public static function download_product()
 {
     $product_id = absint($_GET['download_file']);
     $_product = wc_get_product($product_id);
     $download_data = self::get_download_data(array('product_id' => $product_id, 'order_key' => wc_clean($_GET['order']), 'email' => sanitize_email(str_replace(' ', '+', $_GET['email'])), 'download_id' => wc_clean(isset($_GET['key']) ? preg_replace('/\\s+/', ' ', $_GET['key']) : '')));
     if ($_product && $download_data) {
         self::check_current_user_can_download($download_data);
         do_action('woocommerce_download_product', $download_data->user_email, $download_data->order_key, $download_data->product_id, $download_data->user_id, $download_data->download_id, $download_data->order_id);
         self::count_download($download_data);
         self::download($_product->get_file_download_path($download_data->download_id), $download_data->product_id);
     } else {
         self::download_error(__('Invalid download link.', 'woocommerce'));
     }
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:17,代码来源:class-wc-download-handler.php


示例20: get_posted_attribute

 /**
  * Get and sanitize posted attribute data
  * @return array
  */
 private static function get_posted_attribute()
 {
     $attribute = array('attribute_label' => isset($_POST['attribute_label']) ? wc_clean(stripslashes($_POST['attribute_label'])) : '', 'attribute_name' => isset($_POST['attribute_name']) ? wc_sanitize_taxonomy_name(stripslashes($_POST['attribute_name'])) : '', 'attribute_type' => isset($_POST['attribute_type']) ? wc_clean($_POST['attribute_type']) : 'select', 'attribute_orderby' => isset($_POST['attribute_orderby']) ? wc_clean($_POST['attribute_orderby']) : '', 'attribute_public' => isset($_POST['attribute_public']) ? 1 : 0);
     if (empty($attribute['attribute_type'])) {
         $attribute['attribute_type'] = 'select';
     }
     if (empty($attribute['attribute_label'])) {
         $attribute['attribute_label'] = ucfirst($attribute['attribute_name']);
     }
     if (empty($attribute['attribute_name'])) {
         $attribute['attribute_name'] = wc_sanitize_taxonomy_name($attribute['attribute_label']);
     }
     return $attribute;
 }
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:18,代码来源:class-wc-admin-attributes.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_clear_notices函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_check_if_attribute_name_is_reserved函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap