本文整理汇总了PHP中wc_ship_to_billing_address_only函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_ship_to_billing_address_only函数的具体用法?PHP wc_ship_to_billing_address_only怎么用?PHP wc_ship_to_billing_address_only使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_ship_to_billing_address_only函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_wc_ship_to_billing_address_only
/**
* Test wc_ship_to_billing_address_only().
*
* @since 2.3.0
*/
public function test_wc_ship_to_billing_address_only()
{
$default = get_option('woocommerce_ship_to_destination');
update_option('woocommerce_ship_to_destination', 'shipping');
$this->assertEquals(false, wc_ship_to_billing_address_only());
update_option('woocommerce_ship_to_destination', 'billing_only');
$this->assertEquals(true, wc_ship_to_billing_address_only());
update_option('woocommerce_ship_to_destination', $default);
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:14,代码来源:functions.php
示例2: process_checkout
/**
* Process the checkout after the confirm order button is pressed.
*/
public function process_checkout()
{
try {
if (empty($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-process_checkout')) {
WC()->session->set('refresh_totals', true);
throw new Exception(__('We were unable to process your order, please try again.', 'woocommerce'));
}
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
// Prevent timeout
@set_time_limit(0);
do_action('woocommerce_before_checkout_process');
if (WC()->cart->is_empty()) {
throw new Exception(sprintf(__('Sorry, your session has expired. <a href="%s" class="wc-backward">Return to homepage</a>', 'woocommerce'), home_url()));
}
do_action('woocommerce_checkout_process');
// Checkout fields (not defined in checkout_fields)
$this->posted['terms'] = isset($_POST['terms']) ? 1 : 0;
$this->posted['createaccount'] = isset($_POST['createaccount']) && !empty($_POST['createaccount']) ? 1 : 0;
$this->posted['payment_method'] = isset($_POST['payment_method']) ? stripslashes($_POST['payment_method']) : '';
$this->posted['shipping_method'] = isset($_POST['shipping_method']) ? $_POST['shipping_method'] : '';
$this->posted['ship_to_different_address'] = isset($_POST['ship_to_different_address']) ? true : false;
if (isset($_POST['shiptobilling'])) {
_deprecated_argument('WC_Checkout::process_checkout()', '2.1', 'The "shiptobilling" field is deprecated. The template files are out of date');
$this->posted['ship_to_different_address'] = $_POST['shiptobilling'] ? false : true;
}
// Ship to billing only option
if (wc_ship_to_billing_address_only()) {
$this->posted['ship_to_different_address'] = false;
}
// Update customer shipping and payment method to posted method
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($this->posted['shipping_method']) && is_array($this->posted['shipping_method'])) {
foreach ($this->posted['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', $this->posted['payment_method']);
// Note if we skip shipping
$skipped_shipping = false;
// Get posted checkout_fields and do validation
foreach ($this->checkout_fields as $fieldset_key => $fieldset) {
// Skip shipping if not needed
if ($fieldset_key == 'shipping' && ($this->posted['ship_to_different_address'] == false || !WC()->cart->needs_shipping_address())) {
$skipped_shipping = true;
continue;
}
// Skip account if not needed
if ($fieldset_key == 'account' && (is_user_logged_in() || $this->must_create_account == false && empty($this->posted['createaccount']))) {
continue;
}
foreach ($fieldset as $key => $field) {
if (!isset($field['type'])) {
$field['type'] = 'text';
}
// Get Value
switch ($field['type']) {
case "checkbox":
$this->posted[$key] = isset($_POST[$key]) ? 1 : 0;
break;
case "multiselect":
$this->posted[$key] = isset($_POST[$key]) ? implode(', ', array_map('wc_clean', $_POST[$key])) : '';
break;
case "textarea":
$this->posted[$key] = isset($_POST[$key]) ? wp_strip_all_tags(wp_check_invalid_utf8(stripslashes($_POST[$key]))) : '';
break;
default:
$this->posted[$key] = isset($_POST[$key]) ? is_array($_POST[$key]) ? array_map('wc_clean', $_POST[$key]) : wc_clean($_POST[$key]) : '';
break;
}
// Hooks to allow modification of value
$this->posted[$key] = apply_filters('woocommerce_process_checkout_' . sanitize_title($field['type']) . '_field', $this->posted[$key]);
$this->posted[$key] = apply_filters('woocommerce_process_checkout_field_' . $key, $this->posted[$key]);
// Validation: Required fields
if (isset($field['required']) && $field['required'] && empty($this->posted[$key])) {
switch ($fieldset_key) {
case 'shipping':
$field_label = sprintf(_x('Shipping %s', 'Shipping FIELDNAME', 'woocommerce'), $field['label']);
break;
case 'billing':
$field_label = sprintf(_x('Billing %s', 'Billing FIELDNAME', 'woocommerce'), $field['label']);
break;
default:
$field_label = $field['label'];
break;
}
wc_add_notice(apply_filters('woocommerce_checkout_required_field_notice', sprintf(_x('%s is a required field.', 'FIELDNAME is a required field.', 'woocommerce'), '<strong>' . $field_label . '</strong>'), $field_label), 'error');
}
if (!empty($this->posted[$key])) {
// Validation rules
if (!empty($field['validate']) && is_array($field['validate'])) {
foreach ($field['validate'] as $rule) {
switch ($rule) {
case 'postcode':
$this->posted[$key] = strtoupper(str_replace(' ', '', $this->posted[$key]));
//.........这里部分代码省略.........
开发者ID:unfulvio,项目名称:woocommerce,代码行数:101,代码来源:class-wc-checkout.php
示例3: get_posted_data
/**
* Get posted data from the checkout form.
*
* @since 2.7.0
* @return array of data and errors.
*/
protected function get_posted_data()
{
$data = array('terms' => (int) isset($_POST['terms']), 'createaccount' => (int) (!empty($_POST['createaccount'])), 'payment_method' => isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : '', 'shipping_method' => isset($_POST['shipping_method']) ? wc_clean($_POST['shipping_method']) : '', 'ship_to_different_address' => !empty($_POST['ship_to_different_address']) && !wc_ship_to_billing_address_only(), 'woocommerce_checkout_update_totals' => isset($_POST['woocommerce_checkout_update_totals']));
foreach ($this->get_checkout_fields() as $fieldset_key => $fieldset) {
if ($this->maybe_skip_fieldset($fieldset_key, $data)) {
continue;
}
foreach ($fieldset as $key => $field) {
$type = sanitize_title(isset($field['type']) ? $field['type'] : 'text');
switch ($type) {
case 'checkbox':
$value = (int) isset($_POST[$key]);
break;
case 'multiselect':
$value = isset($_POST[$key]) ? implode(', ', wc_clean($_POST[$key])) : '';
break;
case 'textarea':
$value = isset($_POST[$key]) ? wc_sanitize_textarea($_POST[$key]) : '';
break;
default:
$value = isset($_POST[$key]) ? wc_clean($_POST[$key]) : '';
break;
}
$data[$key] = apply_filters('woocommerce_process_checkout_' . $type . '_field', apply_filters('woocommerce_process_checkout_field_' . $key, $value));
}
}
return $data;
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:34,代码来源:class-wc-checkout.php
示例4: wc_get_customer_orders
//.........这里部分代码省略.........
</td>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
} else {
?>
<div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
<a class="woocommerce-Button button" href="<?php
echo esc_url(apply_filters('woocommerce_return_to_shop_redirect', wc_get_page_permalink('shop')));
?>
">
<?php
_e('Go Shop', 'woocommerce');
?>
</a>
<?php
_e('No order has been made yet.', 'woocommerce');
?>
</div>
<?php
}
?>
<?php
echo '<p><a href="' . esc_url(wc_get_endpoint_url('orders')) . '">Ver Todos</a></p>';
do_action('woocommerce_after_account_orders', $has_orders);
$customer_id = get_current_user_id();
if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
$get_addresses = apply_filters('woocommerce_my_account_get_addresses', array('billing' => __('Billing Address', 'woocommerce'), 'shipping' => __('Shipping Address', 'woocommerce')), $customer_id);
} else {
$get_addresses = apply_filters('woocommerce_my_account_get_addresses', array('billing' => __('Billing Address', 'woocommerce')), $customer_id);
}
$oldcol = 1;
$col = 1;
?>
<?php
if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
echo '<div class="u-columns woocommerce-Addresses col2-set addresses">';
}
?>
<?php
foreach ($get_addresses as $name => $title) {
?>
<div class="u-column<?php
echo ($col = $col * -1) < 0 ? 1 : 2;
?>
col-<?php
echo ($oldcol = $oldcol * -1) < 0 ? 1 : 2;
?>
woocommerce-Address">
<header class="woocommerce-Address-title title">
<h3>Cadastro</h3>
<a href="<?php
echo esc_url(wc_get_endpoint_url('edit-address', $name));
?>
" class="edit"><?php
_e('Edit', 'woocommerce');
?>
</a>
</header>
<address>
<?php
$address = apply_filters('woocommerce_my_account_my_address_formatted_address', array('first_name' => get_user_meta($customer_id, $name . '_first_name', true), 'last_name' => get_user_meta($customer_id, $name . '_last_name', true), 'company' => get_user_meta($customer_id, $name . '_company', true), 'address_1' => get_user_meta($customer_id, $name . '_address_1', true), 'address_2' => get_user_meta($customer_id, $name . '_address_2', true), 'city' => get_user_meta($customer_id, $name . '_city', true), 'state' => get_user_meta($customer_id, $name . '_state', true), 'postcode' => get_user_meta($customer_id, $name . '_postcode', true), 'country' => get_user_meta($customer_id, $name . '_country', true)), $customer_id, $name);
$formatted_address = WC()->countries->get_formatted_address($address);
if (!$formatted_address) {
_e('You have not set up this type of address yet.', 'woocommerce');
} else {
echo $formatted_address;
}
?>
</address>
</div>
<?php
}
?>
<?php
if (!wc_ship_to_billing_address_only() && wc_shipping_enabled()) {
echo '</div>';
}
?>
</div><!-- pedidos -->
<?php
}
开发者ID:willowmagrini,项目名称:dg,代码行数:101,代码来源:functions.php
示例5: wc_get_endpoint_url
<h3 ><?php echo $title; ?></h3>
<a href="<?php echo wc_get_endpoint_url( 'edit-address', $name ); ?>/#myaccount" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
</header>
<address>
<?php
$address = apply_filters( 'woocommerce_my_account_my_address_formatted_address', array(
'first_name' => get_user_meta( $customer_id, $name . '_first_name', true ),
'last_name' => get_user_meta( $customer_id, $name . '_last_name', true ),
'company' => get_user_meta( $customer_id, $name . '_company', true ),
'address_1' => get_user_meta( $customer_id, $name . '_address_1', true ),
'address_2' => get_user_meta( $customer_id, $name . '_address_2', true ),
'city' => get_user_meta( $customer_id, $name . '_city', true ),
'state' => get_user_meta( $customer_id, $name . '_state', true ),
'postcode' => get_user_meta( $customer_id, $name . '_postcode', true ),
'country' => get_user_meta( $customer_id, $name . '_country', true )
), $customer_id, $name );
$formatted_address = WC()->countries->get_formatted_address( $address );
if ( ! $formatted_address )
_e( 'You have not set up this type of address yet.', 'woocommerce' );
else
echo $formatted_address;
?>
</address>
</div>
<?php endforeach; ?>
<?php if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) echo '</div>'; ?>
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:30,代码来源:my-address.php
示例6: wpmp_content_invoice
//.........这里部分代码省略.........
$msg .= '<tbody>';
$total_payment = 0;
$cur_symbol = get_woocommerce_currency_symbol(get_option('woocommerce_currency'));
foreach ($order_detail_by_order_id as $product_id => $details) {
for ($i = 0; $i < count($details); $i++) {
$total_payment = $total_payment + intval($details[$i]['product_total_price']);
if ($details[$i]['variable_id'] == 0) {
$msg .= '<tr>';
$msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; word-wrap: break-word; padding: 12px;">' . $details[$i]['product_name'];
$msg .= '<br>';
$msg .= '<small></small>';
$msg .= '</td>';
$msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">' . $details[$i]['qty'] . '</td>';
$msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">';
$msg .= '<span class="amount">' . $cur_symbol . $details[$i]['product_total_price'] . '</span>';
$msg .= '</td>';
$msg .= '</tr>';
} else {
$product = new WC_Product($product_id);
$attribute = $product->get_attributes();
$attribute_name = '';
foreach ($attribute as $key => $value) {
$attribute_name = $value['name'];
}
$variation = new WC_Product_Variation($details[$i]['variable_id']);
$aaa = $variation->get_variation_attributes();
$attribute_prop = strtoupper($aaa['attribute_' . strtolower($attribute_name)]);
$msg .= '<tr>';
$msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; word-wrap: break-word; padding: 12px;">' . $details[$i]['product_name'];
$msg .= '<br><small>' . $attribute_name . ':' . $attribute_prop . '</small>';
$msg .= '</td>';
$msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">' . $details[$i]['qty'] . '</td>';
$msg .= '<td style="text-align: left; vertical-align: middle; border: 1px solid #eee; padding: 12px;">';
$msg .= '<span class="amount">' . $cur_symbol . $details[$i]['product_total_price'] . '</span>';
$msg .= '</td>';
$msg .= '</tr>';
}
}
}
$msg .= '</tbody>';
$msg .= '<tfoot>';
/*$msg .= '<!-- <tr>';
$msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; border-top-width: 4px; padding: 12px;">Subtotal:</th>';
$msg .= '<td style="text-align: left; border: 1px solid #eee; border-top-width: 4px; padding: 12px;">';
$msg .= '<span class="amount"></span>';
$msg .= '</td>';
$msg .= '</tr> -->';*/
$msg .= '<tr>';
$msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; padding: 12px;">Shipping:</th>';
$msg .= '<td style="text-align: left; border: 1px solid #eee; padding: 12px;">' . $order->get_shipping_method() . '</td>';
$msg .= '</tr>';
$msg .= '<tr>';
$msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; padding: 12px;">Payment Method:</th>';
$msg .= '<td style="text-align: left; border: 1px solid #eee; padding: 12px;">' . $order->payment_method_title . '</td>';
$msg .= '</tr>';
$msg .= '<tr>';
$msg .= '<th scope="row" colspan="2" style="text-align: left; border: 1px solid #eee; padding: 12px;">Total:</th>';
$msg .= '<td style="text-align: left; border: 1px solid #eee; padding: 12px;">';
$msg .= '<span class="amount">' . $total_payment . '</span>';
$msg .= '</td>';
$msg .= '</tr>';
$msg .= '</tfoot>';
$msg .= '</table>';
$msg .= '<h2 style="color: #557da1; display: block; font-size: 18px; font-weight: bold; line-height: 130%; margin: 16px 0 8px; text-align: left;">Customer details</h2>';
$msg .= '<p style="margin: 0 0 16px;">';
$msg .= '<strong>Email:</strong>';
if ($order->billing_email) {
$msg .= $order->billing_email;
}
$msg .= '</p>';
$msg .= '<p style="margin: 0 0 16px;">';
$msg .= '<strong>Tel:</strong>';
if ($order->billing_phone) {
$msg .= $order->billing_phone;
}
$msg .= '</p>';
$msg .= '<table cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">';
$msg .= '<tr>';
$msg .= '<td valign="top" width="50%" style="padding: 12px;">';
$font = ' font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;';
$msg .= "<h3 style='color: #557da1; display: block;" . $font . " font-size: 16px; font-weight: bold; line-height: 130%; margin: 16px 0 8px; text-align: left;'>Billing address</h3>";
$msg .= '<p style="margin: 0 0 16px;">' . $order->get_formatted_billing_address();
$msg .= '</p>';
$msg .= '</td>';
if (!wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ($shipping = $order->get_formatted_shipping_address())) {
$msg .= '<td valign="top" width="50%" style="padding: 12px;">';
$msg .= "<h3 style='color: #557da1; display: block; font-size: 16px; font-weight: bold; line-height: 130%; margin: 16px 0 8px; text-align: left;'>Shipping address</h3>";
$msg .= '<p style="margin: 0 0 16px;">' . $shipping;
$msg .= '</p>';
$msg .= '</td>';
}
$msg .= '</tr>';
$msg .= '</table>';
$msg .= '</div>';
$msg .= '</td>';
$msg .= '</tr>';
$msg .= '</table>';
$msg .= '<!-- End Content -->';
return $msg;
}
开发者ID:pcuervo,项目名称:mobbily-wordpress,代码行数:101,代码来源:class-mp-form-handler.php
示例7:
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.2
*/
if (!defined('ABSPATH')) {
exit;
// Exit if accessed directly
}
/** @global WC_Checkout $checkout */
?>
<div class="woocommerce-billing-fields">
<?php
if (wc_ship_to_billing_address_only() && WC()->cart->needs_shipping()) {
?>
<h3><?php
_e('Billing & Shipping', 'woocommerce');
?>
</h3>
<?php
} else {
?>
<h3><?php
_e('Billing Details', 'woocommerce');
?>
</h3>
开发者ID:tlovett1,项目名称:woocommerce,代码行数:31,代码来源:form-billing.php
示例8: update_order_review
/**
* AJAX update order review on checkout
*/
public static function update_order_review()
{
ob_start();
check_ajax_referer('update-order-review', 'security');
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
if (WC()->cart->is_empty()) {
$data = array('fragments' => apply_filters('woocommerce_update_order_review_fragments', array('form.woocommerce-checkout' => '<div class="woocommerce-error">' . __('Sorry, your session has expired.', 'woocommerce') . ' <a href="' . home_url() . '" class="wc-backward">' . __('Return to homepage', 'woocommerce') . '</a></div>')));
wp_send_json($data);
die;
}
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) {
foreach ($_POST['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', empty($_POST['payment_method']) ? '' : $_POST['payment_method']);
if (isset($_POST['country'])) {
WC()->customer->set_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_address_2($_POST['address_2']);
}
if (wc_ship_to_billing_address_only()) {
if (isset($_POST['country'])) {
WC()->customer->set_shipping_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_shipping_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_shipping_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_shipping_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_shipping_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_shipping_address_2($_POST['address_2']);
}
} else {
if (isset($_POST['s_country'])) {
WC()->customer->set_shipping_country($_POST['s_country']);
}
if (isset($_POST['s_state'])) {
WC()->customer->set_shipping_state($_POST['s_state']);
}
if (isset($_POST['s_postcode'])) {
WC()->customer->set_shipping_postcode($_POST['s_postcode']);
}
if (isset($_POST['s_city'])) {
WC()->customer->set_shipping_city($_POST['s_city']);
}
if (isset($_POST['s_address'])) {
WC()->customer->set_shipping_address($_POST['s_address']);
}
if (isset($_POST['s_address_2'])) {
WC()->customer->set_shipping_address_2($_POST['s_address_2']);
}
}
WC()->cart->calculate_totals();
// Get order review fragment
ob_start();
woocommerce_order_review();
$woocommerce_order_review = ob_get_clean();
// Get checkout payment fragment
ob_start();
woocommerce_checkout_payment();
$woocommerce_checkout_payment = ob_get_clean();
// Get messages if reload checkout is not true
$messages = '';
if (!isset(WC()->session->reload_checkout)) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
}
$data = array('result' => empty($messages) ? 'success' : 'failure', 'messages' => $messages, 'reload' => isset(WC()->session->reload_checkout) ? 'true' : 'false', 'fragments' => apply_filters('woocommerce_update_order_review_fragments', array('.woocommerce-checkout-review-order-table' => $woocommerce_order_review, '.woocommerce-checkout-payment' => $woocommerce_checkout_payment)));
wp_send_json($data);
die;
//.........这里部分代码省略.........
开发者ID:JodiWarren,项目名称:woocommerce,代码行数:101,代码来源:class-wc-ajax.php
示例9: update_order_review
/**
* AJAX update order review on checkout.
*/
public static function update_order_review()
{
check_ajax_referer('update-order-review', 'security');
wc_maybe_define_constant('WOOCOMMERCE_CHECKOUT', true);
if (WC()->cart->is_empty()) {
self::update_order_review_expired();
}
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) {
foreach ($_POST['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', empty($_POST['payment_method']) ? '' : $_POST['payment_method']);
WC()->customer->set_props(array('billing_country' => isset($_POST['country']) ? $_POST['country'] : null, 'billing_state' => isset($_POST['state']) ? $_POST['state'] : null, 'billing_postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : null, 'billing_city' => isset($_POST['city']) ? $_POST['city'] : null, 'billing_address_1' => isset($_POST['address']) ? $_POST['address'] : null, 'billing_address_2' => isset($_POST['address_2']) ? $_POST['address_2'] : null));
if (wc_ship_to_billing_address_only()) {
WC()->customer->set_props(array('shipping_country' => isset($_POST['country']) ? $_POST['country'] : null, 'shipping_state' => isset($_POST['state']) ? $_POST['state'] : null, 'shipping_postcode' => isset($_POST['postcode']) ? $_POST['postcode'] : null, 'shipping_city' => isset($_POST['city']) ? $_POST['city'] : null, 'shipping_address_1' => isset($_POST['address']) ? $_POST['address'] : null, 'shipping_address_2' => isset($_POST['address_2']) ? $_POST['address_2'] : null));
if (!empty($_POST['country'])) {
WC()->customer->set_calculated_shipping(true);
}
} else {
WC()->customer->set_props(array('shipping_country' => isset($_POST['s_country']) ? $_POST['s_country'] : null, 'shipping_state' => isset($_POST['s_state']) ? $_POST['s_state'] : null, 'shipping_postcode' => isset($_POST['s_postcode']) ? $_POST['s_postcode'] : null, 'shipping_city' => isset($_POST['s_city']) ? $_POST['s_city'] : null, 'shipping_address_1' => isset($_POST['s_address']) ? $_POST['s_address'] : null, 'shipping_address_2' => isset($_POST['s_address_2']) ? $_POST['s_address_2'] : null));
if (!empty($_POST['s_country'])) {
WC()->customer->set_calculated_shipping(true);
}
}
WC()->customer->save();
WC()->cart->calculate_totals();
// Get order review fragment
ob_start();
woocommerce_order_review();
$woocommerce_order_review = ob_get_clean();
// Get checkout payment fragment
ob_start();
woocommerce_checkout_payment();
$woocommerce_checkout_payment = ob_get_clean();
// Get messages if reload checkout is not true
$messages = '';
if (!isset(WC()->session->reload_checkout)) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
}
unset(WC()->session->refresh_totals, WC()->session->reload_checkout);
wp_send_json(array('result' => empty($messages) ? 'success' : 'failure', 'messages' => $messages, 'reload' => isset(WC()->session->reload_checkout) ? 'true' : 'false', 'fragments' => apply_filters('woocommerce_update_order_review_fragments', array('.woocommerce-checkout-review-order-table' => $woocommerce_order_review, '.woocommerce-checkout-payment' => $woocommerce_checkout_payment))));
}
开发者ID:woocommerce,项目名称:woocommerce,代码行数:51,代码来源:class-wc-ajax.php
示例10: test_ship_to_billing_address_only
/**
* Test ship_to_billing_address_only method
*/
public function test_ship_to_billing_address_only()
{
$this->assertEquals(wc_ship_to_billing_address_only(), WC()->cart->ship_to_billing_address_only());
}
开发者ID:noahjohn9259,项目名称:woocommerce,代码行数:7,代码来源:cart.php
示例11: wcdn_has_shipping_address
/**
* Check if a shipping address is enabled
*/
function wcdn_has_shipping_address($order)
{
// Works only with WooCommerce 2.2 and higher
if (version_compare(WC_VERSION, '2.2.0', '>=')) {
if (!wc_ship_to_billing_address_only() && $order->needs_shipping_address() && get_option('woocommerce_calc_shipping') !== 'no') {
return true;
} else {
return false;
}
}
return true;
}
开发者ID:sammykumar,项目名称:goodbeads,代码行数:15,代码来源:wcdn-template-functions.php
示例12: test_needs_shipping_address
/**
* Test needs_shipping_address method.
*/
public function test_needs_shipping_address()
{
$needs_shipping_address = false;
if (WC()->cart->needs_shipping() === true && !wc_ship_to_billing_address_only()) {
$needs_shipping_address = true;
}
$this->assertEquals(apply_filters('woocommerce_cart_needs_shipping_address', $needs_shipping_address), WC()->cart->needs_shipping_address());
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:11,代码来源:cart.php
示例13: update_order_review
/**
* AJAX update order review on checkout
*/
public static function update_order_review()
{
check_ajax_referer('update-order-review', 'security');
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
if (0 == sizeof(WC()->cart->get_cart())) {
ob_start();
$data = array('result' => 'failure', 'messages' => '<div class="woocommerce-error">' . __('Sorry, your session has expired.', 'woocommerce') . ' <a href="' . home_url() . '" class="wc-backward">' . __('Return to homepage', 'woocommerce') . '</a></div>', 'html' => '');
// Send JSON
wp_send_json($data);
}
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) {
foreach ($_POST['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', empty($_POST['payment_method']) ? '' : $_POST['payment_method']);
if (isset($_POST['country'])) {
WC()->customer->set_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_address_2($_POST['address_2']);
}
if (wc_ship_to_billing_address_only()) {
if (isset($_POST['country'])) {
WC()->customer->set_shipping_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_shipping_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_shipping_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_shipping_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_shipping_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_shipping_address_2($_POST['address_2']);
}
} else {
if (isset($_POST['s_country'])) {
WC()->customer->set_shipping_country($_POST['s_country']);
}
if (isset($_POST['s_state'])) {
WC()->customer->set_shipping_state($_POST['s_state']);
}
if (isset($_POST['s_postcode'])) {
WC()->customer->set_shipping_postcode($_POST['s_postcode']);
}
if (isset($_POST['s_city'])) {
WC()->customer->set_shipping_city($_POST['s_city']);
}
if (isset($_POST['s_address'])) {
WC()->customer->set_shipping_address($_POST['s_address']);
}
if (isset($_POST['s_address_2'])) {
WC()->customer->set_shipping_address_2($_POST['s_address_2']);
}
}
WC()->cart->calculate_totals();
// Get the review order table
ob_start();
do_action('woocommerce_checkout_order_review', true);
$woocommerce_checkout_order_review = ob_get_clean();
// Get messages if reload checkout is not true
$messages = '';
if (!isset(WC()->session->reload_checkout)) {
ob_start();
wc_print_notices();
$messages = ob_get_clean();
// Wrap messages if not empty
if (!empty($messages)) {
$messages = '<div class="woocommerce-error-ajax">' . $messages . '</div>';
}
}
// Setup data
$data = array('result' => empty($messages) ? 'success' : 'failure', 'messages' => $messages, 'html' => $woocommerce_checkout_order_review);
// Send JSON
//.........这里部分代码省略.........
开发者ID:donpapa26,项目名称:bakancslistad,代码行数:101,代码来源:class-wc-ajax.php
示例14: _e
?>
<header class="title">
<h3><?php
_e('Billing Address', 'woocommerce');
?>
</h3>
</header>
<address data-mh="address-block">
<?php
echo ($address = $order->get_formatted_billing_address()) ? $address : __('N/A', 'woocommerce');
?>
</address>
<?php
if (!wc_ship_to_billing_address_only() && $order->needs_shipping_address()) {
?>
</div><!-- /.col-1 -->
<div class="col-2 address">
<header class="title">
<h3><?php
_e('Shipping Address', 'woocommerce');
?>
</h3>
</header>
<address data-mh="address-block">
<?php
echo ($address = $order->get_formatted_shipping_address()) ? $address : __('N/A', 'woocommerce');
?>
</address>
开发者ID:adrienlementheour,项目名称:AliceRouat,代码行数:31,代码来源:order-details-customer.php
示例15: update_order_review
/**
* AJAX update order review on checkout
*/
public static function update_order_review()
{
check_ajax_referer('update-order-review', 'security');
if (!defined('WOOCOMMERCE_CHECKOUT')) {
define('WOOCOMMERCE_CHECKOUT', true);
}
if (0 == sizeof(WC()->cart->get_cart())) {
echo '<div class="woocommerce-error">' . __('Sorry, your session has expired.', 'woocommerce') . ' <a href="' . home_url() . '" class="wc-backward">' . __('Return to homepage', 'woocommerce') . '</a></div>';
die;
}
do_action('woocommerce_checkout_update_order_review', $_POST['post_data']);
$chosen_shipping_methods = WC()->session->get('chosen_shipping_methods');
if (isset($_POST['shipping_method']) && is_array($_POST['shipping_method'])) {
foreach ($_POST['shipping_method'] as $i => $value) {
$chosen_shipping_methods[$i] = wc_clean($value);
}
}
WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
WC()->session->set('chosen_payment_method', empty($_POST['payment_method']) ? '' : $_POST['payment_method']);
if (isset($_POST['country'])) {
WC()->customer->set_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_address_2($_POST['address_2']);
}
if (wc_ship_to_billing_address_only()) {
if (isset($_POST['country'])) {
WC()->customer->set_shipping_country($_POST['country']);
}
if (isset($_POST['state'])) {
WC()->customer->set_shipping_state($_POST['state']);
}
if (isset($_POST['postcode'])) {
WC()->customer->set_shipping_postcode($_POST['postcode']);
}
if (isset($_POST['city'])) {
WC()->customer->set_shipping_city($_POST['city']);
}
if (isset($_POST['address'])) {
WC()->customer->set_shipping_address($_POST['address']);
}
if (isset($_POST['address_2'])) {
WC()->customer->set_shipping_address_2($_POST['address_2']);
}
} else {
if (isset($_POST['s_country'])) {
WC()->customer->set_shipping_country($_POST['s_country']);
}
if (isset($_POST['s_state'])) {
WC()->customer->set_shipping_state($_POST['s_state']);
}
if (isset($_POST['s_postcode'])) {
WC()->customer->set_shipping_postcode($_POST['s_postcode']);
}
if (isset($_POST['s_city'])) {
WC()->customer->set_shipping_city($_POST['s_city']);
}
if (isset($_POST['s_address'])) {
WC()->customer->set_shipping_address($_POST['s_address']);
}
if (isset($_POST['s_address_2'])) {
WC()->customer->set_shipping_address_2($_POST['s_address_2']);
}
}
WC()->cart->calculate_totals();
do_action('woocommerce_checkout_order_review', true);
// Display review order table
die;
}
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:84,代码来源:class-wc-ajax.php
示例16: _e
_e('Billing Address', 'woocommerce');
?>
</h3>
</header>
<address>
<?php
if (!$order->get_formatted_billing_address()) {
_e('N/A', 'woocommerce');
} else {
echo $order->get_formatted_billing_address();
}
?>
</address>
<?php
if (!wc_ship_to_billing_address_only() && $order->needs_shipping_address() && get_option('woocommerce_calc_shipping') !== 'no') {
?>
</div><!-- /.col-1 -->
<div class="col-2">
<header class="title">
<h3><?php
_e('Shipping Address', 'woocommerce');
?>
</h3>
</header>
<address>
<?php
if (!$order->get_formatted_shipping_address()) {
开发者ID:acd111,项目名称:drunkenmeadow,代码行数:31,代码来源:order-details.php
示例17: get_current_user_id
|
请发表评论