block.json
1 year ago
controller.php
1 year ago
index.asset.php
5 months ago
index.js
5 months ago
style-index-rtl.css
1 year ago
style-index.css
1 year ago
view.php
3 months ago
controller.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | $style = ''; |
| 4 | $style .= ! empty( $attributes['backgroundColor'] ) |
| 5 | ? esc_attr( safecss_filter_attr( 'background-color:' . $attributes['backgroundColor'] ) ) . ';' |
| 6 | : ''; |
| 7 | $style .= ! empty( $attributes['textColor'] ) |
| 8 | ? esc_attr( safecss_filter_attr( 'color:' . $attributes['textColor'] ) ) . ';' |
| 9 | : ''; |
| 10 | |
| 11 | $form = \SureCart::cart()->getForm(); |
| 12 | $form_mode = \SureCart::cart()->getMode(); |
| 13 | |
| 14 | // Stop if no form or mode found as for deletion. |
| 15 | if ( empty( $form->ID ) || empty( $form_mode ) ) { |
| 16 | return ''; |
| 17 | } |
| 18 | |
| 19 | // Don't render if the cart is disabled. |
| 20 | if ( ! \SureCart::cart()->isCartEnabled() ) { |
| 21 | return ''; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Allow filtering of the cart menu icon. |
| 26 | * |
| 27 | * @param string $icon The icon. |
| 28 | * @param string $mode The icon position. |
| 29 | */ |
| 30 | |
| 31 | // pass custom icon if set. |
| 32 | $icon = $attributes['custom_icon'] ?? apply_filters( |
| 33 | 'sc_cart_menu_icon', |
| 34 | SureCart::svg()->get( $attributes['cart_icon'] ?? 'shopping-bag' ), |
| 35 | ); |
| 36 | |
| 37 | wp_interactivity_state( |
| 38 | 'surecart/checkout', |
| 39 | array( |
| 40 | // set derived state for SSR. |
| 41 | 'hasItems' => false, |
| 42 | ) |
| 43 | ); |
| 44 | |
| 45 | // return the view. |
| 46 | return 'file:./view.php'; |
| 47 |