本文整理汇总了PHP中woocommerce_clean函数的典型用法代码示例。如果您正苦于以下问题:PHP woocommerce_clean函数的具体用法?PHP woocommerce_clean怎么用?PHP woocommerce_clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了woocommerce_clean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
private function init()
{
global $woocommerce;
// Load the settings.
$this->init_form_fields();
$this->init_settings();
$this->crates = array();
$this->enabled = $this->get_var('enabled');
$this->title = $this->get_var('title');
$this->debug = $this->get_var('debug');
$this->availability = $this->get_var('availability');
$this->countries = $this->get_var('countries', array());
$this->origin_postalcode = $this->get_var('origin_postalcode');
$this->uri = key($this->uris);
$this->user_id = $this->get_var('user_id');
$this->packing_method = $this->get_var('packing_method');
$this->fee = $this->get_var('fee');
$this->shipping_methods = $this->get_var('shipping_methods', array());
$this->custom_methods = $this->get_var('custom_methods', array());
$this->boxes = $this->get_var('boxes', array());
if (empty($this->custom_methods) && !empty($this->services)) {
foreach ($this->services as $method_key => $method_name) {
$this->custom_methods[$method_key] = array('name' => woocommerce_clean($method_name), 'price_ajustment' => '', 'enabled' => isset($this->settings['shipping_methods']) && array_search($method_key, $this->settings['shipping_methods']) !== false || !isset($this->settings['shipping_methods']) || empty($this->settings['shipping_methods']) ? '1' : '0');
}
}
// Used for weight based packing only
$this->max_weight = '150';
add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options'));
add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'clear_transients'));
parent::__construct();
}
示例2: process_payment
/**
* Process the payment
*/
function process_payment($order_id)
{
global $woocommerce;
if (class_exists('WC_Subscriptions_Order') && WC_Subscriptions_Order::order_contains_subscription($order_id)) {
$order = new WC_Order($order_id);
$stripe_token = isset($_POST['stripe_token']) ? woocommerce_clean($_POST['stripe_token']) : '';
// Use Stripe CURL API for payment
try {
$post_data = array();
$customer_id = 0;
// Check if paying via customer ID
if (isset($_POST['stripe_customer_id']) && $_POST['stripe_customer_id'] !== 'new' && is_user_logged_in()) {
$customer_ids = get_user_meta(get_current_user_id(), '_stripe_customer_id', false);
if (isset($customer_ids[$_POST['stripe_customer_id']]['customer_id'])) {
$customer_id = $customer_ids[$_POST['stripe_customer_id']]['customer_id'];
} else {
throw new Exception(__('Invalid card.', 'wc_stripe'));
}
} elseif (empty($stripe_token)) {
throw new Exception(__('Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'wc_stripe'));
}
if (method_exists('WC_Subscriptions_Order', 'get_total_initial_payment')) {
$initial_payment = WC_Subscriptions_Order::get_total_initial_payment($order);
} else {
$initial_payment = WC_Subscriptions_Order::get_sign_up_fee($order) + WC_Subscriptions_Order::get_price_per_period($order);
}
$customer_response = $this->add_customer_to_order($order, $customer_id, $stripe_token);
if ($initial_payment > 0) {
$payment_response = $this->process_subscription_payment($order, $initial_payment);
}
if (is_wp_error($customer_response)) {
throw new Exception($customer_response->get_error_message());
} else {
if (isset($payment_response) && is_wp_error($payment_response)) {
throw new Exception($payment_response->get_error_message());
} else {
// Payment complete
$order->payment_complete();
// Remove cart
$woocommerce->cart->empty_cart();
// Activate subscriptions
WC_Subscriptions_Manager::activate_subscriptions_for_order($order);
// Store token
if ($stripe_token) {
update_post_meta($order->id, '_stripe_token', $stripe_token);
}
// Return thank you page redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}
}
} catch (Exception $e) {
$woocommerce->add_error(__('Error:', 'wc_stripe') . ' "' . $e->getMessage() . '"');
return;
}
} else {
return parent::process_payment($order_id);
}
}
示例3: custom_woocommerce_get_catalog_ordering_args
function custom_woocommerce_get_catalog_ordering_args($args)
{
$orderby_value = isset($_GET['orderby']) ? woocommerce_clean($_GET['orderby']) : apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'));
if ('stock' == $orderby_value) {
$args['orderby'] = '_stock';
$args['order'] = 'ASC';
$args['meta_key'] = '';
}
return $args;
}
示例4: output
/**
* Output the cart shortcode.
*
* @access public
* @param array $atts
* @return void
*/
public static function output($atts)
{
global $woocommerce;
if (!defined('WOOCOMMERCE_CART')) {
define('WOOCOMMERCE_CART', true);
}
// Add Discount
if (!empty($_POST['apply_coupon'])) {
if (!empty($_POST['coupon_code'])) {
$woocommerce->cart->add_discount(sanitize_text_field($_POST['coupon_code']));
} else {
$woocommerce->add_error(WC_Coupon::get_generic_coupon_error(WC_Coupon::E_WC_COUPON_PLEASE_ENTER));
}
// Remove Coupon Codes
} elseif (isset($_GET['remove_discounts'])) {
$woocommerce->cart->remove_coupons($_GET['remove_discounts']);
// Update Shipping
} elseif (!empty($_POST['calc_shipping']) && $woocommerce->verify_nonce('cart')) {
$validation = $woocommerce->validation();
$woocommerce->shipping->reset_shipping();
$woocommerce->customer->calculated_shipping(true);
$country = woocommerce_clean($_POST['calc_shipping_country']);
$state = woocommerce_clean($_POST['calc_shipping_state']);
$postcode = apply_filters('woocommerce_shipping_calculator_enable_postcode', true) ? woocommerce_clean($_POST['calc_shipping_postcode']) : '';
$city = apply_filters('woocommerce_shipping_calculator_enable_city', false) ? woocommerce_clean($_POST['calc_shipping_city']) : '';
if ($postcode && !$validation->is_postcode($postcode, $country)) {
$woocommerce->add_error(__('Please enter a valid postcode/ZIP.', 'woocommerce'));
$postcode = '';
} elseif ($postcode) {
$postcode = $validation->format_postcode($postcode, $country);
}
if ($country) {
// Update customer location
$woocommerce->customer->set_location($country, $state, $postcode, $city);
$woocommerce->customer->set_shipping_location($country, $state, $postcode, $city);
$woocommerce->add_message(__('Shipping costs updated.', 'woocommerce'));
} else {
$woocommerce->customer->set_to_base();
$woocommerce->customer->set_shipping_to_base();
$woocommerce->add_message(__('Shipping costs updated.', 'woocommerce'));
}
do_action('woocommerce_calculated_shipping');
}
// Check cart items are valid
do_action('woocommerce_check_cart_items');
// Calc totals
$woocommerce->cart->calculate_totals();
if (sizeof($woocommerce->cart->get_cart()) == 0) {
//woocommerce_get_template( 'cart/cart-empty.php' );
woocommerce_get_template('checkout/form-checkout.php');
} else {
//woocommerce_get_template( 'cart/cart.php' );
woocommerce_get_template('checkout/form-checkout.php');
}
}
示例5: woocommerce_catalog_ordering
/**
* Output the product sorting options.
*
* @access public
* @subpackage Loop
* @return void
*/
function woocommerce_catalog_ordering()
{
global $woocommerce;
$orderby = isset($_GET['orderby']) ? woocommerce_clean($_GET['orderby']) : apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'));
/**
* Show options for ordering
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
if (!defined('ABSPATH')) {
exit;
}
// Exit if accessed directly
global $woocommerce, $wp_query;
if (1 == $wp_query->found_posts || !woocommerce_products_will_display()) {
return;
}
?>
<form class="woocommerce-ordering" method="get">
<div class="woocommerce-ordering-div">
<select name="orderby" class="orderby">
<?php
$catalog_orderby = apply_filters('woocommerce_catalog_orderby', array('menu_order' => __('Default sorting', 'woocommerce'), 'popularity' => __('Sort by popularity', 'woocommerce'), 'rating' => __('Sort by average rating', 'woocommerce'), 'date' => __('Sort by newness', 'woocommerce'), 'price' => __('Sort by price: low to high', 'woocommerce'), 'price-desc' => __('Sort by price: high to low', 'woocommerce')));
if (get_option('woocommerce_enable_review_rating') == 'no') {
unset($catalog_orderby['rating']);
}
foreach ($catalog_orderby as $id => $name) {
echo '<option value="' . esc_attr($id) . '" ' . selected($orderby, $id, false) . '>' . esc_attr($name) . '</option>';
}
?>
</select>
</div>
<?php
// Keep query string vars intact
foreach ($_GET as $key => $val) {
if ('orderby' == $key) {
continue;
}
if (is_array($val)) {
foreach ($val as $innerVal) {
echo '<input type="hidden" name="' . esc_attr($key) . '[]" value="' . esc_attr($innerVal) . '" />';
}
} else {
echo '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($val) . '" />';
}
}
?>
</form>
<?php
}
示例6: find_rates
/**
* Searches for all matching country/state/postcode tax rates.
*
* @access public
* @param string $args (default: '')
* @return array
*/
public function find_rates($args = array(), $deprecated_state = null, $deprecated_postcode = null, $deprecated_class = null)
{
global $wpdb;
// Make sure the arguments match the WC 2.0 structure
if (is_string($args)) {
_deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["country"] instead. Deprecated argument will be removed in WC 2.1.');
$args = array('country' => $args);
}
if (func_num_args() > 1) {
if (null !== $deprecated_state) {
_deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["state"] instead. Deprecated argument will be removed in WC 2.1.');
$args['state'] = $deprecated_state;
}
if (null !== $deprecated_postcode) {
_deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["postcode"] instead. Deprecated argument will be removed in WC 2.1.');
$args['postcode'] = $deprecated_postcode;
}
if (null !== $deprecated_class) {
_deprecated_argument(__CLASS__ . '->' . __FUNCTION__, '2.0', 'Use $args["tax_class"] instead. Deprecated argument will be removed in WC 2.1.');
$args['tax_class'] = $deprecated_class;
}
}
$defaults = array('country' => '', 'state' => '', 'city' => '', 'postcode' => '', 'tax_class' => '');
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);
if (!$country) {
return array();
}
// Handle postcodes
$valid_postcodes = array('*', strtoupper(woocommerce_clean($postcode)));
// Work out possible valid wildcard postcodes
$postcode_length = strlen($postcode);
$wildcard_postcode = strtoupper(woocommerce_clean($postcode));
for ($i = 0; $i < $postcode_length; $i++) {
$wildcard_postcode = substr($wildcard_postcode, 0, -1);
$valid_postcodes[] = $wildcard_postcode . '*';
}
// Run the query
$found_rates = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT tax_rates.* FROM\n\t\t\t\t{$wpdb->prefix}woocommerce_tax_rates as tax_rates\n\t\t\tLEFT OUTER JOIN\n\t\t\t\t{$wpdb->prefix}woocommerce_tax_rate_locations as locations ON tax_rates.tax_rate_id = locations.tax_rate_id\n\t\t\tWHERE\n\t\t\t\ttax_rate_country IN ( %s, '' )\n\t\t\t\tAND tax_rate_state IN ( %s, '' )\n\t\t\t\tAND tax_rate_class = %s\n\t\t\t\tAND (\n\t\t\t\t\t(\n\t\t\t\t\t\tlocations.location_type = 'postcode' AND locations.location_code IN ('" . implode("','", $valid_postcodes) . "')\n\t\t\t\t\t)\n\t\t\t\t\tOR\n\t\t\t\t\t(\n\t\t\t\t\t\tlocations.location_type = 'city' AND locations.location_code = %s\n\t\t\t\t\t)\n\t\t\t\t\tOR locations.location_type IS null\n\t\t\t\t)\n\t\t\tGROUP BY\n\t\t\t\ttax_rate_priority\n\t\t\tORDER BY\n\t\t\t\ttax_rate_priority, tax_rate_order\n\t\t\t", strtoupper($country), strtoupper($state), sanitize_title($tax_class), strtoupper($city)));
// Put results into array
$matched_tax_rates = array();
foreach ($found_rates as $found_rate) {
$matched_tax_rates[$found_rate->tax_rate_id] = array('rate' => $found_rate->tax_rate, 'label' => $found_rate->tax_rate_name, 'shipping' => $found_rate->tax_rate_shipping ? 'yes' : 'no', 'compound' => $found_rate->tax_rate_compound ? 'yes' : 'no');
}
/*
echo '<pre>' . __( 'Matched tax rates:', 'woocommerce' );
var_dump( $matched_tax_rates );
echo '</pre>';
*/
return apply_filters('woocommerce_matched_tax_rates', $matched_tax_rates, $country, $state, $postcode, $city, $tax_class);
}
示例7: createCard
public function createCard($giftInformation)
{
global $wpdb;
if (isset($giftInformation['rpgc_description'])) {
$giftCard['description'] = woocommerce_clean($giftInformation['rpgc_description']);
}
if (isset($giftInformation['rpgc_to'])) {
$giftCard['to'] = woocommerce_clean($giftInformation['rpgc_to']);
}
if (isset($giftInformation['rpgc_email_to'])) {
$giftCard['toEmail'] = woocommerce_clean($giftInformation['rpgc_email_to']);
}
if (isset($giftInformation['rpgc_from'])) {
$giftCard['from'] = woocommerce_clean($giftInformation['rpgc_from']);
}
if (isset($giftInformation['rpgc_email_from'])) {
$giftCard['fromEmail'] = woocommerce_clean($giftInformation['rpgc_email_from']);
}
if (isset($giftInformation['rpgc_amount'])) {
$giftCard['amount'] = woocommerce_clean($giftInformation['rpgc_amount']);
if (!isset($giftInformation['rpgc_balance'])) {
$giftCard['balance'] = woocommerce_clean($giftInformation['rpgc_amount']);
$giftCard['sendTheEmail'] = 1;
}
}
if (isset($giftInformation['rpgc_balance'])) {
$giftCard['balance'] = woocommerce_clean($giftInformation['rpgc_balance']);
}
if (isset($giftInformation['rpgc_note'])) {
$giftCard['note'] = woocommerce_clean($giftInformation['rpgc_note']);
}
if (isset($giftInformation['rpgc_expiry_date'])) {
$giftCard['expiry_date'] = woocommerce_clean($giftInformation['rpgc_expiry_date']);
} else {
$giftCard['expiry_date'] = '';
}
if ($_POST['post_title'] == '' || isset($giftInformation['rpgc_regen_number'])) {
if ($giftInformation['rpgc_regen_number'] == 'yes' || $_POST['post_title'] == '') {
$newNumber = apply_filters('rpgc_regen_number', $this->generateNumber());
$wpdb->update($wpdb->posts, array('post_title' => $newNumber), array('ID' => $_POST['ID']));
$wpdb->update($wpdb->posts, array('post_name' => $newNumber), array('ID' => $_POST['ID']));
}
}
if ($giftCard['sendTheEmail'] == 1 && $giftCard['balance'] != 0 || isset($giftInformation['rpgc_resend_email'])) {
$email = new WPR_Giftcard_Email();
$post = get_post($_POST['ID']);
$email->sendEmail($post);
}
update_post_meta($_POST['ID'], '_wpr_giftcard', $giftCard);
}
示例8: process_payment
/**
* Process the payment
*/
function process_payment($order_id)
{
global $woocommerce;
if (class_exists('WC_Sponsorship_Order') && WC_Sponsorship_Order::order_contains_sponsorship($order_id)) {
$order = new WC_Order($order_id);
$stripe_token = isset($_POST['stripe_token']) ? woocommerce_clean($_POST['stripe_token']) : '';
// Use Stripe CURL API for payment
try {
$post_data = array();
$customer_id = 0;
// Check if paying via customer ID
if (isset($_POST['stripe_customer_id']) && $_POST['stripe_customer_id'] !== 'new' && is_user_logged_in()) {
$customer_ids = get_user_meta(get_current_user_id(), '_stripe_customer_id', false);
if (isset($customer_ids[$_POST['stripe_customer_id']]['customer_id'])) {
$customer_id = $customer_ids[$_POST['stripe_customer_id']]['customer_id'];
} else {
throw new Exception(__('Invalid card.', 'wc_stripe'));
}
} elseif (empty($stripe_token)) {
throw new Exception(__('Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'wc_stripe'));
}
$customer_response = $this->add_customer_to_order($order, $customer_id, $stripe_token);
$customer_response = $this->add_customer_to_order($order, $stripe_token);
if (is_wp_error($customer_response)) {
throw new Exception($customer_response->get_error_message());
} else {
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', 'Awaiting the sponsorship project\'s goal to be met.');
// Empty awaiting payment session
if (defined($_SESSION) && array_key_exists('order_awaiting_payment', $_SESSION)) {
unset($_SESSION['order_awaiting_payment']);
}
// Remove cart
$woocommerce->cart->empty_cart();
// Store token
if ($stripe_token) {
update_post_meta($order->id, '_stripe_token', $stripe_token);
}
// Return thank you page redirect
return array('result' => 'success', 'redirect' => $this->get_return_url($order));
}
} catch (Exception $e) {
$woocommerce->add_error(__('Error:', 'wc_stripe') . ' "' . $e->getMessage() . '"');
return;
}
} else {
return parent::process_payment($order_id);
}
}
示例9: save_admin_settings
function save_admin_settings()
{
if (!is_admin()) {
return;
}
$permalinks = array();
foreach ($this->taxonomies as $taxonomy) {
if (isset($_POST['pe_wc_product_' . $taxonomy . '_slug'])) {
$permalinks[$taxonomy . '_tax_base'] = untrailingslashit(woocommerce_clean($_POST['pe_wc_product_' . $taxonomy . '_slug']));
}
}
if (!empty($permalinks)) {
update_option('pe_wc_permalinks', $permalinks);
flush_rewrite_rules();
}
}
示例10: rf_process_giftcard_meta
function rf_process_giftcard_meta($post_id, $post)
{
global $wpdb, $woocommerce_errors;
$code = '';
$coupon_type = '';
$coupon_amount = '';
$description = '';
$product_id = '';
$usage_limit = '';
$expiry_date = '';
$wpdb->update($wpdb->posts, array('post_title' => $post->post_title), array('ID' => $post_id));
if (isset($_POST['rf_coupon_type'])) {
$coupon_type = woocommerce_clean($_POST['rf_coupon_type']);
update_post_meta($post_id, 'rf_coupon_type', $coupon_type);
}
if (isset($_POST['rf_coupon_amount'])) {
$coupon_amount = woocommerce_clean($_POST['rf_coupon_amount']);
update_post_meta($post_id, 'rf_coupon_amount', $coupon_amount);
}
if (isset($_POST['rf_description'])) {
$description = woocommerce_clean($_POST['rf_description']);
update_post_meta($post_id, 'rf_description', $description);
}
if (isset($_POST['rf_product_id'])) {
$product_id = woocommerce_clean($_POST['rf_product_id']);
update_post_meta($post_id, 'rf_product_id', $product_id);
}
if (isset($_POST['rf_usage'])) {
$usage = woocommerce_clean($_POST['rf_usage']);
update_post_meta($post_id, 'rf_usage', $usage);
}
if (isset($_POST['rf_limit'])) {
$limit = woocommerce_clean($_POST['rf_limit']);
update_post_meta($post_id, 'rf_limit', $limit);
}
if (isset($_POST['rf_expiry_date'])) {
$expiry_date = woocommerce_clean($_POST['rf_expiry_date']);
update_post_meta($post_id, 'rf_expiry_date', $expiry_date);
}
if (isset($_POST['rf_type'])) {
$type = woocommerce_clean($_POST['rf_type']);
update_post_meta($post_id, 'rf_type', $type);
}
/* Deprecated - same hook name as in the meta */
do_action('woocommerce_rf_options');
do_action('woocommerce_rf_options_save');
}
示例11: output
/**
* Output the shortcode.
*
* @access public
* @param array $atts
* @return void
*/
public static function output($atts)
{
global $woocommerce;
$woocommerce->show_messages();
$order = false;
// Get the order
$order_id = apply_filters('woocommerce_thankyou_order_id', empty($_GET['order']) ? 0 : absint($_GET['order']));
$order_key = apply_filters('woocommerce_thankyou_order_key', empty($_GET['key']) ? '' : woocommerce_clean($_GET['key']));
if ($order_id > 0) {
$order = new WC_Order($order_id);
if ($order->order_key != $order_key) {
unset($order);
}
}
// Empty awaiting payment session
unset($woocommerce->session->order_awaiting_payment);
woocommerce_get_template('checkout/thankyou.php', array('order' => $order));
}
示例12: get_cart_item_data
/**
* Process this field after being posted
* @return array on success, WP_ERROR on failure
*/
public function get_cart_item_data()
{
$cart_item_data = array();
foreach ($this->addon['options'] as $option) {
$field_name = $this->get_field_name() . '-' . sanitize_title($option['label']);
if (!empty($_FILES[$field_name]) && !empty($_FILES[$field_name]['name'])) {
$upload = $this->handle_upload($_FILES[$field_name]);
if (empty($upload['error']) && !empty($upload['file'])) {
$value = woocommerce_clean($upload['url']);
$cart_item_data[] = array('name' => $this->get_option_label($option), 'value' => $value, 'display' => basename($value), 'price' => $this->get_option_price($option));
} else {
return new WP_Error('addon-error', $upload['error']);
}
} elseif (isset($this->value[sanitize_title($option['label'])])) {
$cart_item_data[] = array('name' => $this->get_option_label($option), 'value' => $this->value[sanitize_title($option['label'])], 'display' => basename($this->value[sanitize_title($option['label'])]), 'price' => $this->get_option_price($option));
}
}
return $cart_item_data;
}
示例13: order_actions
/**
* Perform order actions for amazon
*/
public function order_actions()
{
check_ajax_referer('amazon_order_action', 'security');
$order_id = absint($_POST['order_id']);
$id = isset($_POST['amazon_id']) ? woocommerce_clean($_POST['amazon_id']) : '';
$action = sanitize_title($_POST['amazon_action']);
switch ($action) {
case 'refresh':
$this->clear_stored_states($order_id);
break;
case 'authorize':
// Delete old
delete_post_meta($order_id, 'amazon_authorization_id');
delete_post_meta($order_id, 'amazon_capture_id');
$this->authorize_payment($order_id, $id, false);
$this->clear_stored_states($order_id);
break;
case 'authorize_capture':
// Delete old
delete_post_meta($order_id, 'amazon_authorization_id');
delete_post_meta($order_id, 'amazon_capture_id');
$this->authorize_payment($order_id, $id, true);
$this->clear_stored_states($order_id);
break;
case 'close_authorization':
$this->close_authorization($order_id, $id);
$this->clear_stored_states($order_id);
break;
case 'capture':
$this->capture_payment($order_id, $id);
$this->clear_stored_states($order_id);
break;
case 'refund':
$amazon_refund_amount = floatval(woocommerce_clean($_POST['amazon_refund_amount']));
$amazon_refund_note = woocommerce_clean($_POST['amazon_refund_note']);
$this->refund_payment($order_id, $id, $amazon_refund_amount, $amazon_refund_note);
$this->clear_stored_states($order_id);
break;
}
die;
}
示例14: output
/**
* Output the shortcode.
*
* @access public
* @param array $atts
* @return void
*/
public static function output($atts)
{
global $woocommerce;
$woocommerce->show_messages();
$order = false;
// Get the order
//echo $order_id = apply_filters( 'woocommerce_thankyou_order_id', empty( $_GET['order'] ) ? 0 : absint( $_GET['order'] ) );
$order_id = base64_decode(base64_decode(str_replace('564|||', '', $_GET['order'])));
$order_key = apply_filters('woocommerce_thankyou_order_key', empty($_GET['key']) ? '' : woocommerce_clean($_GET['key']));
if ($order_id > 0) {
$order = new WC_Order($order_id);
//echo $order->order_key;
/*echo '<pre>';
print_r($order);echo '</pre>';*/
/*if ( $order->order_key != $order_key )
unset( $order );*/
}
// Empty awaiting payment session
unset($woocommerce->session->order_awaiting_payment);
woocommerce_get_template('checkout/thankyou.php', array('order' => $order));
}
示例15: siw_wc_catalog_ordering
function siw_wc_catalog_ordering($args)
{
$orderby_value = isset($_GET['orderby']) ? woocommerce_clean($_GET['orderby']) : apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'));
switch ($orderby_value) {
case 'random':
$sort_args['orderby'] = 'rand';
$sort_args['order'] = '';
$sort_args['meta_key'] = '';
break;
case 'startdate':
$sort_args['orderby'] = 'meta_value';
$sort_args['order'] = 'asc';
$sort_args['meta_key'] = 'startdatum';
break;
case 'country':
$sort_args['orderby'] = 'meta_value';
$sort_args['order'] = 'asc';
$sort_args['meta_key'] = 'land';
break;
}
return $sort_args;
}