| 1 |
<?php |
| 2 |
namespace Sellkit\Blocks\Inner_Block; |
| 3 |
|
| 4 |
defined( 'ABSPATH' ) || exit; |
| 5 |
|
| 6 |
/** |
| 7 |
* Checkout_Payment_Continue class. |
| 8 |
* |
| 9 |
* @since 2.3.0 |
| 10 |
* @package Sellkit\Blocks\Inner_Block |
| 11 |
*/ |
| 12 |
class Checkout_Payment_Continue { |
| 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 continue. |
| 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_continue( $content, $attributes ) { |
| 33 |
add_filter( 'sellkit_block_checkout_place_order_btn_text', function() { |
| 34 |
return esc_html( $attributes['paymentContinueButtonText'] ); |
| 35 |
} ); |
| 36 |
|
| 37 |
ob_start(); |
| 38 |
?> |
| 39 |
<section class="place-order sellkit-one-page-checkout-place-order <?php echo esc_attr( $attributes['customClassName'] ); ?>"> |
| 40 |
<noscript> |
| 41 |
<?php |
| 42 |
//phpcs:disable |
| 43 |
/* translators: $1 and $2 opening and closing emphasis tags respectively */ |
| 44 |
printf( esc_html__( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the %1$sUpdate Totals%2$s button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'sellkit' ), '<em>', '</em>' ); |
| 45 |
//phpcs:enable |
| 46 |
?> |
| 47 |
<br/><button type="submit" class="button alt sellkit-checkout-widget-primary-button" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'sellkit' ); ?>"><?php esc_html_e( 'Update totals', 'sellkit' ); ?></button> |
| 48 |
</noscript> |
| 49 |
|
| 50 |
<?php $order_button_text = $attributes['paymentContinueButtonText']; ?> |
| 51 |
|
| 52 |
<?php do_action( 'woocommerce_review_order_before_submit' ); ?> |
| 53 |
|
| 54 |
<?php echo apply_filters( 'woocommerce_order_button_html', '<button type="submit" class="button alt sellkit-checkout-widget-primary-button" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>' ); // @codingStandardsIgnoreLine ?> |
| 55 |
|
| 56 |
<?php do_action( 'woocommerce_review_order_after_submit' ); ?> |
| 57 |
|
| 58 |
<?php wp_nonce_field( 'woocommerce-process_checkout', 'woocommerce-process-checkout-nonce' ); ?> |
| 59 |
<?php do_action( 'sellkit_block_checkout_required_hidden_fields' ); ?> |
| 60 |
<?php /* Hide place order button container after ajax call update. we already have it at bottom */ ?> |
| 61 |
<script> |
| 62 |
jQuery( document ).ajaxComplete( function() { |
| 63 |
jQuery( '#payment > .place-order' ).css( 'display', 'none' ).hide(); |
| 64 |
} ); |
| 65 |
</script> |
| 66 |
</section> |
| 67 |
<?php |
| 68 |
$final_content = ob_get_clean(); |
| 69 |
|
| 70 |
return str_replace( '</div>', $final_content . '</div>', $content ); |
| 71 |
} |
| 72 |
} |
| 73 |
|