block.json
11 months ago
controller.php
1 year ago
index.asset.php
6 months ago
index.js
6 months ago
view.php
4 months ago
view.php
61 lines
| 1 | <div <?php |
| 2 | echo wp_kses_data( |
| 3 | get_block_wrapper_attributes( |
| 4 | array( |
| 5 | 'class' => 'wp-block-button ' . esc_attr( $width_class ), |
| 6 | 'data-sc-block-id' => 'product-buy-button', |
| 7 | ) |
| 8 | ) |
| 9 | ); |
| 10 | ?> |
| 11 | <?php |
| 12 | echo wp_kses_data( |
| 13 | wp_interactivity_data_wp_context( |
| 14 | array( |
| 15 | 'checkoutUrl' => esc_url( \SureCart::pages()->url( 'checkout' ) ), |
| 16 | 'buttonText' => $attributes['text'] ?? ( $add_to_cart ? __( 'Add to Cart', 'surecart' ) : __( 'Buy Now', 'surecart' ) ), |
| 17 | 'outOfStockText' => esc_attr( $attributes['out_of_stock_text'] ?? __( 'Sold Out', 'surecart' ) ), |
| 18 | 'unavailableText' => esc_attr( $attributes['unavailable_text'] ?? __( 'Unavailable', 'surecart' ) ), |
| 19 | 'addToCart' => $add_to_cart ?? true, |
| 20 | ) |
| 21 | ) |
| 22 | ); |
| 23 | ?> |
| 24 | > |
| 25 | <?php if ( ! $add_to_cart ) { ?> |
| 26 | <button |
| 27 | class="wp-block-button__link wp-element-button sc-button__link <?php echo ! empty( $styles['classnames'] ) ? esc_attr( $styles['classnames'] ) : ''; ?>" |
| 28 | data-wp-bind--disabled="state.isUnavailable" |
| 29 | style="<?php echo ! empty( $styles['css'] ) ? esc_attr( $styles['css'] ) : ''; ?>" |
| 30 | data-wp-on--click="callbacks.redirectToCheckout" |
| 31 | <?php if ( 'never' !== $attributes['show_sticky_purchase_button'] ) { ?> |
| 32 | data-wp-on-window--scroll="surecart/sticky-purchase::actions.toggleVisibility" |
| 33 | data-wp-on-window--resize="surecart/sticky-purchase::actions.toggleVisibility" |
| 34 | <?php } ?> |
| 35 | > |
| 36 | <span class="sc-button__link-text" data-wp-text="state.buttonText"> |
| 37 | </span> |
| 38 | </button> |
| 39 | <?php |
| 40 | } else { |
| 41 | ?> |
| 42 | <button |
| 43 | class="wp-block-button__link wp-element-button sc-button__link <?php echo ! empty( $styles['classnames'] ) ? esc_attr( $styles['classnames'] ) : ''; ?>" |
| 44 | data-wp-bind--disabled="state.isUnavailable" |
| 45 | data-wp-class--sc-button__link--busy="context.busy" |
| 46 | style="<?php echo ! empty( $styles['css'] ) ? esc_attr( $styles['css'] ) : ''; ?>" |
| 47 | <?php if ( 'never' !== $attributes['show_sticky_purchase_button'] ) { ?> |
| 48 | data-wp-on-window--scroll="surecart/sticky-purchase::actions.toggleVisibility" |
| 49 | data-wp-on-window--resize="surecart/sticky-purchase::actions.toggleVisibility" |
| 50 | <?php } ?> |
| 51 | > |
| 52 | <span class="sc-spinner" aria-hidden="true"></span> |
| 53 | <span class="sc-button__link-text" data-wp-text="state.buttonText"> |
| 54 | </span> |
| 55 | </button> |
| 56 | <?php |
| 57 | } |
| 58 | ?> |
| 59 | </div> |
| 60 | |
| 61 | <?php \SureCart::render( 'blocks/sticky-purchase', [ 'settings' => $attributes ] ); ?> |