Skip to content

Commit

Permalink
Version 1.10.0 (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
mntzrr authored Jun 19, 2024
2 parents 1dd7e4f + 654f37c commit 65626a5
Show file tree
Hide file tree
Showing 11 changed files with 1,639 additions and 1,690 deletions.
19 changes: 14 additions & 5 deletions assets/js/dintero-checkout-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ jQuery( function ( $ ) {
update = true
}

if ( shippingAddress ) {
if (
dinteroCheckoutParams.allowDifferentBillingShippingAddress &&
shippingAddress &&
Object.keys( shippingAddress ).length > 1
) {
if ( shippingAddress.co_address ) {
shippingAddress.first_name =
shippingAddress.first_name ||
Expand All @@ -379,9 +383,9 @@ jQuery( function ( $ ) {
shippingAddress.business_name
}

if ( shippingAddress.length > 1 ) {
$( "#ship-to-different-address-checkbox" ).prop( "checked", true )
}
$( "#ship-to-different-address-checkbox" ).prop( "checked", true )
$( "#ship-to-different-address-checkbox" ).change()
$( "#ship-to-different-address-checkbox" ).blur()

if ( "first_name" in shippingAddress ) {
$( "#shipping_first_name" ).val( shippingAddress.first_name )
Expand All @@ -392,7 +396,11 @@ jQuery( function ( $ ) {
}

if ( "business_name" in shippingAddress ) {
$( "#billing_company" ).val( shippingAddress.business_name )
if ( 0 === $( "#billing_company" ).length ) {
$( "#billing_company" ).val( shippingAddress.business_name )
}

$( "#shipping_company" ).val( shippingAddress.business_name )
}

if ( "address_line" in shippingAddress ) {
Expand All @@ -409,6 +417,7 @@ jQuery( function ( $ ) {

if ( "country" in shippingAddress ) {
$( "#shipping_country" ).val( shippingAddress.country )
$( "#shipping_country" ).change()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion assets/js/dintero-checkout-express.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/dintero-checkout-express.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/dintero-checkout-web-sdk.umd.min.js

Large diffs are not rendered by default.

37 changes: 19 additions & 18 deletions classes/class-dintero-checkout-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,25 @@ public function enqueue_scripts() {
'dintero-checkout',
'dinteroCheckoutParams',
array(
'SID' => $session_id,
'language' => substr( get_locale(), 0, 2 ),
'change_payment_method_url' => WC_AJAX::get_endpoint( 'dintero_checkout_wc_change_payment_method' ),
'change_payment_method_nonce' => wp_create_nonce( 'dintero_checkout_wc_change_payment_method' ),
'standardWooCheckoutFields' => $standard_woo_checkout_fields,
'submitOrder' => WC_AJAX::get_endpoint( 'checkout' ),
'log_to_file_url' => WC_AJAX::get_endpoint( 'dintero_checkout_wc_log_js' ),
'log_to_file_nonce' => wp_create_nonce( 'dintero_checkout_wc_log_js' ),
'unset_session_url' => WC_AJAX::get_endpoint( 'dintero_checkout_unset_session' ),
'unset_session_nonce' => wp_create_nonce( 'dintero_checkout_unset_session' ),
'print_notice_url' => WC_AJAX::get_endpoint( 'dintero_checkout_print_notice' ),
'print_notice_nonce' => wp_create_nonce( 'dintero_checkout_print_notice' ),
'shipping_in_iframe' => ( isset( $settings['express_shipping_in_iframe'] ) && 'yes' === $settings['express_shipping_in_iframe'] && 'express' === $settings['checkout_type'] ),
'pip_text' => __( 'Payment in progress', 'dintero-checkout-for-woocommerce' ),
'popOut' => 'yes' === ( $settings['checkout_popout'] ?? 'no' ) ? true : false,
'verifyOrderTotalURL' => WC_AJAX::get_endpoint( 'dintero_verify_order_total' ),
'verifyOrderTotalNonce' => wp_create_nonce( 'dintero_verify_order_total' ),
'verifyOrderTotalError' => __( 'The cart was modified. Please try again.', 'dintero-checkout-for-woocommerce' ),
'SID' => $session_id,
'language' => substr( get_locale(), 0, 2 ),
'change_payment_method_url' => WC_AJAX::get_endpoint( 'dintero_checkout_wc_change_payment_method' ),
'change_payment_method_nonce' => wp_create_nonce( 'dintero_checkout_wc_change_payment_method' ),
'standardWooCheckoutFields' => $standard_woo_checkout_fields,
'submitOrder' => WC_AJAX::get_endpoint( 'checkout' ),
'log_to_file_url' => WC_AJAX::get_endpoint( 'dintero_checkout_wc_log_js' ),
'log_to_file_nonce' => wp_create_nonce( 'dintero_checkout_wc_log_js' ),
'unset_session_url' => WC_AJAX::get_endpoint( 'dintero_checkout_unset_session' ),
'unset_session_nonce' => wp_create_nonce( 'dintero_checkout_unset_session' ),
'print_notice_url' => WC_AJAX::get_endpoint( 'dintero_checkout_print_notice' ),
'print_notice_nonce' => wp_create_nonce( 'dintero_checkout_print_notice' ),
'shipping_in_iframe' => ( isset( $settings['express_shipping_in_iframe'] ) && 'yes' === $settings['express_shipping_in_iframe'] && 'express' === $settings['checkout_type'] ),
'pip_text' => __( 'Payment in progress', 'dintero-checkout-for-woocommerce' ),
'popOut' => 'yes' === ( $settings['checkout_popout'] ?? 'no' ) ? true : false,
'verifyOrderTotalURL' => WC_AJAX::get_endpoint( 'dintero_verify_order_total' ),
'verifyOrderTotalNonce' => wp_create_nonce( 'dintero_verify_order_total' ),
'verifyOrderTotalError' => __( 'The cart was modified. Please try again.', 'dintero-checkout-for-woocommerce' ),
'allowDifferentBillingShippingAddress' => 'yes' === ( $settings['express_allow_different_billing_shipping_address'] ?? 'no' ) ? true : false,
)
);

Expand Down
8 changes: 8 additions & 0 deletions classes/class-dintero-checkout-settings-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ public static function setting_fields() {
'label' => __( 'Enable', 'dintero-checkout-for-woocommerce' ),
'desc_tip' => __( 'Will make the shipping selection happen in the Dintero checkout iframe instead of the shipping section in WooCommerce.', 'dintero-checkout-for-woocommerce' ),
),
'express_allow_different_billing_shipping_address' => array(
'title' => __( 'Allow separate shipping address', 'dintero-checkout-for-woocommerce' ),
'label' => __( 'Allow separate shipping address', 'dintero-checkout-for-woocommerce' ),
'type' => 'checkbox',
'description' => __( 'By default, the billing address is used as the shipping address even if the customer provides the latter. If you want to allow separate billing and shipping address, enable this setting.', 'dintero-checkout-for-woocommerce' ),
'default' => 'no',
'desc_tip' => true,
),

/*
TODO: These options will be added in a future iteration.
Expand Down
14 changes: 14 additions & 0 deletions classes/requests/post/class-dintero-checkout-create-session.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public function get_body() {
'profile_id' => $this->settings['profile_id'],
);

// 'billing' => Default to customer billing address
// 'shipping' => Default to customer shipping address
// 'billing_only' => Force shipping to the customer billing address only.
$shipping_destination = get_option( 'woocommerce_ship_to_destination' );

$separate_shipping = wc_string_to_bool( $this->settings['express_allow_different_billing_shipping_address'] ?? 'no' );
if ( 'billing_only' !== $shipping_destination && $separate_shipping ) {
$customer_type = $this->settings['express_customer_type'];
$customer_type = 'b2bc' === $customer_type ? array( 'b2c', 'b2b' ) : $customer_type;
$body['configuration']['allow_different_billing_shipping_address'] = $customer_type;

// By default this configuration is an empty array, therefore, we don't have to set it if $separate_shipping is set to false.
}

$billing_address = isset( $order ) ? $helper->get_billing_address( $order ) : $helper->get_billing_address();
if ( ! empty( $billing_address ) ) {
$body['order']['billing_address'] = $billing_address;
Expand Down
2 changes: 2 additions & 0 deletions dintero-checkout-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ function () {
*/
public function declare_wc_compatibility() {
// Declare HPOS compatibility.
// Declare Checkout Blocks incompatibility
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, false );
}
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dintero-checkout-for-woocommerce",
"version": "1.9.3",
"version": "1.10.0",
"repository": "git@github.com:Dintero/Dintero.Checkout.WooCommerce.V2.git",
"author": "Krokedil <info@krokedil.se>",
"license": "GPL-3.0+",
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@dintero/checkout-web-sdk": "^0.6.0",
"@dintero/checkout-web-sdk": "^0.8.0",
"grunt-cli": "^1.4.3",
"grunt-zip": "^0.18.2"
}
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tested up to: 6.4.1
Requires PHP: 7.0
WC requires at least: 6.1.0
WC tested up to: 8.2.1
Stable tag: 1.9.3
Stable tag: 1.10.0
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -82,6 +82,12 @@ Go to [https://www.dintero.com/contact-us](https://www.dintero.com/contact-us) t
1. The plugin settings screen where you set up the details to connect to Dintero.

== Changelog ==
= 2024.06.19 - version 1.10.0 =
* Feature - Add support for different billing and shipping address in Express checkout.
* Fix - The shipping company should now be saved to the order as intended.
* Tweak - WooCommerce Blocks is not yet supported.
* Tweak - Updated Web SDK to v0.8.8.

= 2024.05.27 - version 1.9.3 =
* Tweak - Respond with a 500 status code in callback if the order is not found.
* Tweak - Account for manually refunded items in calculation when performing a capture.
Expand Down
Loading

0 comments on commit 65626a5

Please sign in to comment.