[2.2] Merge ship to billing and billing only options
+ update options, update files to use new option + function Closes #5284
This commit is contained in:
parent
e3cb3a4cc8
commit
937db45913
|
@ -94,39 +94,36 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Shipping Display Mode', 'woocommerce' ),
|
||||
'desc' => __( 'This controls how multiple shipping methods are displayed on the frontend.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_shipping_method_format',
|
||||
'default' => '',
|
||||
'type' => 'radio',
|
||||
'title' => __( 'Shipping Display Mode', 'woocommerce' ),
|
||||
'desc' => __( 'This controls how multiple shipping methods are displayed on the frontend.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_shipping_method_format',
|
||||
'default' => '',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'' => __( 'Display shipping methods with "radio" buttons', 'woocommerce' ),
|
||||
'select' => __( 'Display shipping methods in a dropdown', 'woocommerce' ),
|
||||
'' => __( 'Display shipping methods with "radio" buttons', 'woocommerce' ),
|
||||
'select' => __( 'Display shipping methods in a dropdown', 'woocommerce' ),
|
||||
),
|
||||
'desc_tip' => true,
|
||||
'autoload' => false
|
||||
'desc_tip' => true,
|
||||
'autoload' => false
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Shipping Destination', 'woocommerce' ),
|
||||
'desc' => __( 'Ship to billing address by default', 'woocommerce' ),
|
||||
'id' => 'woocommerce_ship_to_billing',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'title' => __( 'Shipping Destination', 'woocommerce' ),
|
||||
'desc' => __( 'This controls which shipping address is used by default.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_ship_to_billing',
|
||||
'default' => 'shipping',
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'' => __( 'Default to shipping address', 'woocommerce' ),
|
||||
'billing' => __( 'Default to billing address', 'woocommerce' ),
|
||||
'billing_only' => __( 'Only ship to the users billing address', 'woocommerce' ),
|
||||
),
|
||||
'autoload' => false,
|
||||
'desc_tip' => true,
|
||||
'show_if_checked' => 'option',
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Only ship to the users billing address', 'woocommerce' ),
|
||||
'id' => 'woocommerce_ship_to_billing_address_only',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
'autoload' => false,
|
||||
'show_if_checked' => 'yes',
|
||||
),
|
||||
//woocommerce_ship_to_billing_address_only
|
||||
|
||||
array(
|
||||
'title' => __( 'Restrict shipping to Location(s)', 'woocommerce' ),
|
||||
|
|
|
@ -188,7 +188,7 @@ class WC_AJAX {
|
|||
if ( isset( $_POST['address_2'] ) )
|
||||
WC()->customer->set_address_2( $_POST['address_2'] );
|
||||
|
||||
if ( "yes" == get_option( 'woocommerce_ship_to_billing_address_only' ) ) {
|
||||
if ( wc_ship_to_billing_address_only() ) {
|
||||
|
||||
if ( isset( $_POST['country'] ) )
|
||||
WC()->customer->set_shipping_country( $_POST['country'] );
|
||||
|
|
|
@ -1399,7 +1399,7 @@ class WC_Cart {
|
|||
* @return bool
|
||||
*/
|
||||
public function ship_to_billing_address_only() {
|
||||
return get_option('woocommerce_ship_to_billing_address_only') == 'yes';
|
||||
return wc_ship_to_billing_address_only();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* Update WC to 2.2.0
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Updates
|
||||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Update options
|
||||
$woocommerce_ship_to_destination = 'shipping';
|
||||
|
||||
if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'yes' ) {
|
||||
$woocommerce_ship_to_destination = 'billing_only';
|
||||
} elseif ( get_option( 'woocommerce_ship_to_billing' ) === 'yes' ) {
|
||||
$woocommerce_ship_to_destination = 'billing';
|
||||
}
|
||||
|
||||
add_option( 'woocommerce_ship_to_destination', $woocommerce_ship_to_destination, '', 'no' );
|
|
@ -290,3 +290,11 @@ function wc_cart_totals_shipping_method_label( $method ) {
|
|||
|
||||
return apply_filters( 'woocommerce_cart_shipping_method_full_label', $label, $method );
|
||||
}
|
||||
|
||||
/**
|
||||
* See if we only ship to billing addresses
|
||||
* @return bool
|
||||
*/
|
||||
function wc_ship_to_billing_address_only() {
|
||||
return 'billing_only' === get_option( 'woocommerce_ship_to_destination' );
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<?php
|
||||
if ( empty( $_POST ) ) {
|
||||
|
||||
$ship_to_different_address = get_option( 'woocommerce_ship_to_billing' ) === 'no' ? 1 : 0;
|
||||
$ship_to_different_address = get_option( 'woocommerce_ship_to_destination' ) === 'shipping' ? 1 : 0;
|
||||
$ship_to_different_address = apply_filters( 'woocommerce_ship_to_different_address_checked', $ship_to_different_address );
|
||||
|
||||
} else {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates/Emails
|
||||
* @version 1.6.4
|
||||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
</td>
|
||||
|
||||
<?php if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
|
||||
<?php if ( ! wc_ship_to_billing_address_only() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
|
||||
|
||||
<td valign="top" width="50%">
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates/Emails/Plain
|
||||
* @version 2.0.0
|
||||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
echo "\n" . __( 'Billing address', 'woocommerce' ) . ":\n";
|
||||
echo $order->get_formatted_billing_address() . "\n\n";
|
||||
|
||||
if ( get_option( 'woocommerce_ship_to_billing_address_only' ) == 'no' && ( $shipping = $order->get_formatted_shipping_address() ) ) :
|
||||
if ( ! wc_ship_to_billing_address_only() && ( $shipping = $order->get_formatted_shipping_address() ) ) :
|
||||
|
||||
echo __( 'Shipping address', 'woocommerce' ) . ":\n";
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.0.0
|
||||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -13,7 +13,7 @@ global $woocommerce;
|
|||
|
||||
$customer_id = get_current_user_id();
|
||||
|
||||
if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) {
|
||||
if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) {
|
||||
$page_title = apply_filters( 'woocommerce_my_account_my_address_title', __( 'My Addresses', 'woocommerce' ) );
|
||||
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
|
||||
'billing' => __( 'Billing Address', 'woocommerce' ),
|
||||
|
@ -35,7 +35,7 @@ $col = 1;
|
|||
<?php echo apply_filters( 'woocommerce_my_account_my_address_description', __( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ) ); ?>
|
||||
</p>
|
||||
|
||||
<?php if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) echo '<div class="col2-set addresses">'; ?>
|
||||
<?php if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) echo '<div class="col2-set addresses">'; ?>
|
||||
|
||||
<?php foreach ( $get_addresses as $name => $title ) : ?>
|
||||
|
||||
|
@ -70,4 +70,4 @@ $col = 1;
|
|||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) echo '</div>'; ?>
|
||||
<?php if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) echo '</div>'; ?>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 2.1.0
|
||||
* @version 2.2.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
@ -106,7 +106,7 @@ $order = new WC_Order( $order_id );
|
|||
?>
|
||||
</dl>
|
||||
|
||||
<?php if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) : ?>
|
||||
<?php if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) : ?>
|
||||
|
||||
<div class="col2-set addresses">
|
||||
|
||||
|
@ -123,7 +123,7 @@ $order = new WC_Order( $order_id );
|
|||
?>
|
||||
</p></address>
|
||||
|
||||
<?php if ( get_option( 'woocommerce_ship_to_billing_address_only' ) === 'no' && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) : ?>
|
||||
<?php if ( ! wc_ship_to_billing_address_only() && get_option( 'woocommerce_calc_shipping' ) !== 'no' ) : ?>
|
||||
|
||||
</div><!-- /.col-1 -->
|
||||
|
||||
|
|
Loading…
Reference in New Issue