Skip to content

Commit

Permalink
Support new shipment setting screens.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Sep 10, 2024
1 parent 37496ed commit e469398
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function get_title() {

public function get_content() {
$content = '<p>' . sprintf( __( 'We found that one of your country options is set to Afghanistan. There is a <a href="%s">known bug</a> in WooCommerce which may lead to this issue. An incorrect country option can have unwanted effects on, among other things, tax calculation and shipping.', 'woocommerce-germanized' ), 'https://github.com/woocommerce/woocommerce/issues/32301' ) . '</p>';
$content .= '<p>' . sprintf( __( 'Please check your <a href="%1$s">general settings</a> and your <a href="%2$s">shipment address settings</a>.', 'woocommerce-germanized' ), admin_url( 'admin.php?page=wc-settings&tab=general' ), admin_url( 'admin.php?page=wc-settings&tab=germanized-shipments&section=address' ) ) . '</p>';
$content .= '<p>' . sprintf( __( 'Please check your <a href="%1$s">general settings</a> and your <a href="%2$s">shipment address settings</a>.', 'woocommerce-germanized' ), admin_url( 'admin.php?page=wc-settings&tab=general' ), admin_url( 'admin.php?page=wc-settings&tab=shipments-general&section=business_information' ) ) . '</p>';

return $content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function get_pointers() {
'color' => array(
'target' => '#woocommerce_gzd_display_checkout_table_color',
'next' => '',
'next_url' => admin_url( 'admin.php?page=wc-settings&tab=germanized-shipments&tutorial=yes' ),
'next_url' => admin_url( 'admin.php?page=wc-settings&tab=shipments&tutorial=yes' ),
'next_trigger' => array(),
'options' => array(
'content' => '<h3>' . esc_html__( 'Product table background', 'woocommerce-germanized' ) . '</h3><p>' . esc_html__( 'The product table within your checkout should be noticeable for your customers. You might want to choose a different background color for it.', 'woocommerce-germanized' ) . '</p>',
Expand Down
10 changes: 0 additions & 10 deletions includes/class-wc-gzd-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,6 @@ public function __construct() {
* Other services (e.g. virtual, services) are not taxable in northern ireland
*/
add_action( 'woocommerce_before_calculate_totals', array( $this, 'maybe_remove_northern_ireland_taxes' ), 15 );

/**
* Tell the shipment integration whether prices include taxes or not.
*/
add_filter(
'woocommerce_gzd_shipments_additional_costs_include_tax',
function() {
return wc_gzd_additional_costs_include_tax();
}
);
}

public function maybe_remove_northern_ireland_taxes( $cart ) {
Expand Down
16 changes: 0 additions & 16 deletions includes/class-wc-gzd-order-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public function __construct() {
*/
add_action( 'woocommerce_order_item_after_calculate_taxes', array( $this, 'recalculate_order_item_unit_price' ), 60, 1 );

add_filter( 'woocommerce_gzd_shipment_order_supports_email_transmission', array( $this, 'shipment_order_supports_email_transmission' ), 10, 2 );

// Add Title to billing address format
add_filter(
'woocommerce_order_formatted_billing_address',
Expand Down Expand Up @@ -159,20 +157,6 @@ function() {
}
}

/**
* @param boolean $supports_email_transmission
* @param \Vendidero\Germanized\Shipments\Order $order
*
* @return boolean
*/
public function shipment_order_supports_email_transmission( $supports_email_transmission, $order ) {
if ( wc_gzd_order_supports_parcel_delivery_reminder( $order->get_id() ) ) {
$supports_email_transmission = true;
}

return $supports_email_transmission;
}

/**
* @param WC_Order_Item $item
* @param WC_Order_Item|false $old_item
Expand Down
16 changes: 16 additions & 0 deletions src/Blocks/PaymentGateways/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public function __construct( $assets ) {
$this->assets = $assets;
}

public function get_supported_features() {
return array(
'products',
'subscriptions',
'subscription_cancellation',
'subscription_suspension',
'subscription_reactivation',
'subscription_amount_changes',
'subscription_date_changes',
'subscription_payment_method_change',
'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin',
'multiple_subscriptions',
);
}

/**
* Initializes the payment method type.
*/
Expand Down
58 changes: 49 additions & 9 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,37 @@ protected function init() {

$this->register_dependencies();
$this->register_payment_methods();
$this->setup_shipments_integration();

if ( did_action( 'woocommerce_blocks_loaded' ) ) {
$this->load_blocks();
} else {
add_action(
'woocommerce_blocks_loaded',
function() {
$this->load_blocks();
}
);
}
}

private function setup_shipments_integration() {
/**
* Tell the shipment integration whether prices include taxes or not.
*/
add_filter(
'woocommerce_gzd_shipments_additional_costs_include_tax',
function() {
return wc_gzd_additional_costs_include_tax();
}
);

add_filter(
'woocommerce_gzd_shipments_template_path',
function() {
return Package::get_template_path();
}
);

add_filter(
'woocommerce_gzd_dhl_get_i18n_path',
Expand Down Expand Up @@ -77,16 +108,25 @@ function() {
}
);

if ( did_action( 'woocommerce_blocks_loaded' ) ) {
$this->load_blocks();
} else {
add_action(
'woocommerce_blocks_loaded',
function() {
$this->load_blocks();
add_filter(
'woocommerce_gzd_shipment_order_supports_email_transmission',
function( $supports_email_transmission, $order ) {
if ( wc_gzd_order_supports_parcel_delivery_reminder( $order->get_id() ) ) {
$supports_email_transmission = true;
}
);
}

return $supports_email_transmission;
},
10,
2
);

add_filter(
'woocommerce_gzd_shipments_last_tutorial_url',
function() {
return admin_url( 'admin.php?page=wc-settings&tab=germanized-emails&tutorial=yes' );
}
);
}

protected function load_blocks() {
Expand Down
4 changes: 4 additions & 0 deletions src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public static function get_language_path() {
return self::$gzd_instance->language_path();
}

public static function get_template_path() {
return self::$gzd_instance->template_path();
}

public static function is_pro() {
return self::$gzd_instance->is_pro();
}
Expand Down

0 comments on commit e469398

Please sign in to comment.