| 1 |
<?php |
| 2 |
namespace Sellkit\Blocks\Inner_Block; |
| 3 |
|
| 4 |
defined( 'ABSPATH' ) || exit; |
| 5 |
|
| 6 |
/** |
| 7 |
* Payment class. |
| 8 |
* |
| 9 |
* @since 2.3.0 |
| 10 |
* @package Sellkit\Blocks\Inner_Block |
| 11 |
*/ |
| 12 |
class Checkout_Payment { |
| 13 |
/** |
| 14 |
* Register block meta. |
| 15 |
* |
| 16 |
* @since 2.3.0 |
| 17 |
*/ |
| 18 |
public function register_block_meta() { |
| 19 |
register_block_type_from_metadata( |
| 20 |
__DIR__ |
| 21 |
); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Render payment. |
| 26 |
* |
| 27 |
* @param string $content Block content. |
| 28 |
* @param array $attributes Block attributes. |
| 29 |
* @since 2.3.0 |
| 30 |
* @return string |
| 31 |
*/ |
| 32 |
public function checkout_payment( $content, $attributes ) { |
| 33 |
add_filter( 'sellkit_checkout_block_secure_transaction_text', function() { |
| 34 |
return esc_html( $attributes['paymentDescriptionText'] ); |
| 35 |
} ); |
| 36 |
|
| 37 |
ob_start(); |
| 38 |
|
| 39 |
if ( ! wp_doing_ajax() ) { |
| 40 |
do_action( 'woocommerce_review_order_before_payment' ); |
| 41 |
|
| 42 |
$custom_class = ! empty( $attributes['customClass'] ) ? esc_attr( $attributes['customClassName'] ) : ''; |
| 43 |
|
| 44 |
echo '<section class="' . esc_attr( $custom_class ) . '">'; |
| 45 |
} |
| 46 |
|
| 47 |
if ( ! wp_doing_ajax() ) { |
| 48 |
?> |
| 49 |
<div id="payment_method_title" class="sellkit-one-page-checkout-payment-heading heading"><?php echo esc_html( $attributes['paymentHeadingText'] ); ?></div> |
| 50 |
<p class="sellkit-one-page-checkout-payment-desc sub-heading"> |
| 51 |
<?php echo esc_html( $attributes['paymentDescriptionText'] ); ?> |
| 52 |
</p> |
| 53 |
<?php |
| 54 |
} |
| 55 |
?> |
| 56 |
<div id="payment" class="woocommerce-checkout-payment sellkit-one-page-checkout-payment-methods sellkit-checkout-widget-divider"> |
| 57 |
<?php if ( ! empty( WC()->cart ) && WC()->cart->needs_payment() ) : ?> |
| 58 |
<ul class="wc_payment_methods payment_methods methods"> |
| 59 |
<?php |
| 60 |
$available_gateways = WC()->payment_gateways->get_available_payment_gateways(); |
| 61 |
|
| 62 |
if ( ! empty( $available_gateways ) ) { |
| 63 |
foreach ( $available_gateways as $gateway ) { |
| 64 |
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) ); |
| 65 |
echo '<hr class="sellkit-checkout-widget-divider">'; |
| 66 |
} |
| 67 |
} else { |
| 68 |
$wc_no_available_payment = apply_filters( 'woocommerce_no_available_payment_methods_message', WC()->customer->get_billing_country() ? esc_html__( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'sellkit' ) : esc_html__( 'Please fill in your details above to see available payment methods.', 'sellkit' ) ); |
| 69 |
|
| 70 |
echo '<li class="woocommerce-notice woocommerce-notice--info woocommerce-info">' . wp_kses_post( $wc_no_available_payment ) . '</li>'; |
| 71 |
} |
| 72 |
?> |
| 73 |
</ul> |
| 74 |
<?php endif; ?> |
| 75 |
</div> |
| 76 |
<?php |
| 77 |
if ( ! wp_doing_ajax() ) { |
| 78 |
?> |
| 79 |
<div class="sellkit-one-page-checkout-payment-desc sub-heading"> |
| 80 |
<?php wc_get_template( 'checkout/terms.php' ); ?> |
| 81 |
</div> |
| 82 |
<?php do_action( 'sellkit_block_checkout_after_term_and_condition' ); ?> |
| 83 |
<?php |
| 84 |
echo '</section>'; |
| 85 |
do_action( 'woocommerce_review_order_after_payment' ); |
| 86 |
} |
| 87 |
|
| 88 |
$final_content = ob_get_clean(); |
| 89 |
|
| 90 |
return str_replace( '</div>', $final_content . '</div>', $content ); |
| 91 |
} |
| 92 |
} |
| 93 |
|