Automattic\WooCommerce\Internal\StockNotifications\Emails
EmailManager::maybe_restore_customer_tax_location_data
Restore customer tax location data from notification's metadata to display product prices in emails using the customer's tax location, if applicable.
Метод класса: EmailManager{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$EmailManager = new EmailManager(); $EmailManager->maybe_restore_customer_tax_location_data( $notification );
- $notification(Notification) (обязательный)
- The notification object.
Код EmailManager::maybe_restore_customer_tax_location_data() EmailManager::maybe restore customer tax location data WC 11.2.2
public function maybe_restore_customer_tax_location_data( $notification ) {
// No need if stores displaying price excluding tax.
if ( TaxDisplayMode::INCLUSIVE !== get_option( 'woocommerce_tax_display_shop' ) ) {
return;
}
// Check if for some reason (e.g., 3PD), a WC_Customer is already assigned into the BG process's context.
if ( ! empty( WC()->customer ) ) {
return;
}
// Get the recorded customer data, if any.
$location = $notification->get_meta( '_customer_location_data' );
if ( empty( $location ) || ! is_array( $location ) || 4 !== count( $location ) ) {
return;
}
// Restore the tax location.
add_filter(
'woocommerce_get_tax_location',
function () use ( $location ) {
return $location;
}
);
}