mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🐛 Hide shipping options for non-physical products
This commit is contained in:
parent
44a4830480
commit
975660d905
1 changed files with 13 additions and 3 deletions
|
@ -431,10 +431,20 @@ class Button implements ButtonInterface {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function script_data(): array {
|
public function script_data(): array {
|
||||||
|
$use_shipping_form = $this->settings->has( 'googlepay_button_shipping_enabled' ) && $this->settings->get( 'googlepay_button_shipping_enabled' );
|
||||||
|
|
||||||
|
// On the product page, only show the shipping form for physical products.
|
||||||
|
$context = $this->context();
|
||||||
|
if ( $use_shipping_form && 'product' === $context ) {
|
||||||
|
$product = wc_get_product();
|
||||||
|
|
||||||
|
if ( ! $product || $product->is_downloadable() || $product->is_virtual() ) {
|
||||||
|
$use_shipping_form = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$shipping = array(
|
$shipping = array(
|
||||||
'enabled' => $this->settings->has( 'googlepay_button_shipping_enabled' )
|
'enabled' => $use_shipping_form,
|
||||||
? boolval( $this->settings->get( 'googlepay_button_shipping_enabled' ) )
|
|
||||||
: false,
|
|
||||||
'configured' => wc_shipping_enabled() && wc_get_shipping_method_count( false, true ) > 0,
|
'configured' => wc_shipping_enabled() && wc_get_shipping_method_count( false, true ) > 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue