|
@@ 458-500 (lines=43) @@
|
| 455 |
|
* @since 4.0.0 |
| 456 |
|
* @version 4.0.0 |
| 457 |
|
*/ |
| 458 |
|
public function display_payment_request_button_html() { |
| 459 |
|
$gateways = WC()->payment_gateways->get_available_payment_gateways(); |
| 460 |
|
|
| 461 |
|
if ( ! isset( $gateways['stripe'] ) ) { |
| 462 |
|
return; |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) { |
| 466 |
|
return; |
| 467 |
|
} |
| 468 |
|
|
| 469 |
|
if ( is_product() && apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false ) ) { |
| 470 |
|
return; |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
if ( is_product() ) { |
| 474 |
|
global $post; |
| 475 |
|
|
| 476 |
|
$product = wc_get_product( $post->ID ); |
| 477 |
|
|
| 478 |
|
if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) { |
| 479 |
|
return; |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
// Pre Orders charge upon release not supported. |
| 483 |
|
if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) { |
| 484 |
|
WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' ); |
| 485 |
|
return; |
| 486 |
|
} |
| 487 |
|
} else { |
| 488 |
|
if ( ! $this->allowed_items_in_cart() ) { |
| 489 |
|
WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' ); |
| 490 |
|
return; |
| 491 |
|
} |
| 492 |
|
} |
| 493 |
|
?> |
| 494 |
|
<div id="wc-stripe-payment-request-wrapper" style="clear:both;padding-top:1.5em;"> |
| 495 |
|
<div id="wc-stripe-payment-request-button"> |
| 496 |
|
<!-- A Stripe Element will be inserted here. --> |
| 497 |
|
</div> |
| 498 |
|
</div> |
| 499 |
|
<?php |
| 500 |
|
} |
| 501 |
|
|
| 502 |
|
/** |
| 503 |
|
* Display payment request button separator. |
|
@@ 508-546 (lines=39) @@
|
| 505 |
|
* @since 4.0.0 |
| 506 |
|
* @version 4.0.0 |
| 507 |
|
*/ |
| 508 |
|
public function display_payment_request_button_separator_html() { |
| 509 |
|
$gateways = WC()->payment_gateways->get_available_payment_gateways(); |
| 510 |
|
|
| 511 |
|
if ( ! isset( $gateways['stripe'] ) ) { |
| 512 |
|
return; |
| 513 |
|
} |
| 514 |
|
|
| 515 |
|
if ( ! is_cart() && ! is_checkout() && ! is_product() && ! isset( $_GET['pay_for_order'] ) ) { |
| 516 |
|
return; |
| 517 |
|
} |
| 518 |
|
|
| 519 |
|
if ( is_product() && apply_filters( 'wc_stripe_hide_payment_request_on_product_page', false ) ) { |
| 520 |
|
return; |
| 521 |
|
} |
| 522 |
|
|
| 523 |
|
if ( is_product() ) { |
| 524 |
|
global $post; |
| 525 |
|
|
| 526 |
|
$product = wc_get_product( $post->ID ); |
| 527 |
|
|
| 528 |
|
if ( ! is_object( $product ) || ! in_array( ( WC_Stripe_Helper::is_pre_30() ? $product->product_type : $product->get_type() ), $this->supported_product_types() ) ) { |
| 529 |
|
return; |
| 530 |
|
} |
| 531 |
|
|
| 532 |
|
// Pre Orders charge upon release not supported. |
| 533 |
|
if ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Product::product_is_charged_upon_release( $product ) ) { |
| 534 |
|
WC_Stripe_Logger::log( 'Pre Order charge upon release is not supported. ( Payment Request button disabled )' ); |
| 535 |
|
return; |
| 536 |
|
} |
| 537 |
|
} else { |
| 538 |
|
if ( ! $this->allowed_items_in_cart() ) { |
| 539 |
|
WC_Stripe_Logger::log( 'Items in the cart has unsupported product type ( Payment Request button disabled )' ); |
| 540 |
|
return; |
| 541 |
|
} |
| 542 |
|
} |
| 543 |
|
?> |
| 544 |
|
<p id="wc-stripe-payment-request-button-separator" style="margin-top:1.5em;text-align:center;display:none;">- <?php esc_html_e( 'OR', 'woocommerce-gateway-stripe' ); ?> -</p> |
| 545 |
|
<?php |
| 546 |
|
} |
| 547 |
|
|
| 548 |
|
/** |
| 549 |
|
* Log errors coming from Payment Request |