Add cart button integration for block and classic themes - #2928
Open
sazedul-haque wants to merge 6 commits into
Open
sazedul-haque wants to merge 6 commits into
sazedul-haque wants to merge 6 commits into
Conversation
- Add Gutenberg cart button block for block theme integration - Enable cart button usage in any block theme - Add global cart button function for classic theme integration - Add [tutor_cart_button] shortcode for theme developers - Add customization options: show/hide icon, show/hide count, custom CSS class - Add cart count badge with WooCommerce-style positioning and styling
harunollyo
requested changes
Sep 17, 2026
| $atts = array( | ||
| 'show_icon' => 'true', | ||
| 'show_count' => isset( $attributes['showCount'] ) ? $attributes['showCount'] : 'if_has_items', | ||
| 'class' => isset( $attributes['customClass'] ) && ! empty( $attributes['customClass'] ) ? $attributes['customClass'] : 'cart-contents', |
Collaborator
There was a problem hiding this comment.
May be we are missing tutor prefix for classname
| ...(iconColor && { '--tutor-cart-icon-color': iconColor }), | ||
| } } | ||
| > | ||
| <svg |
Collaborator
There was a problem hiding this comment.
Can we use external svg file path?
| 'class' => isset( $attributes['customClass'] ) && ! empty( $attributes['customClass'] ) ? $attributes['customClass'] : 'cart-contents', | ||
| ); | ||
|
|
||
| $shortcode = '[tutor_cart_button'; |
Collaborator
There was a problem hiding this comment.
Use sprintf
$shortcode = '[tutor_cart_button';
foreach ( $atts as $key => $value ) {
$shortcode .= sprintf( ' %s="%s"', $key, esc_attr( $value ) );
}
$shortcode .= ']';| public function tutor_cart_button( $atts ) { | ||
| $atts = shortcode_atts( | ||
| array( | ||
| 'class' => 'cart-contents', |
Collaborator
There was a problem hiding this comment.
the default should be start with tutor- prefix
|
|
||
| ob_start(); | ||
| ?> | ||
| <a class="<?php echo esc_attr( $args['class'] ); ?>" href="<?php echo esc_url( $cart_url ); ?>" |
Collaborator
There was a problem hiding this comment.
This element only has an option to show or hide the icon. If show_icon is false, the element should not be rendered.
| return 0; | ||
| } | ||
|
|
||
| $cart_items = tutor_get_cart_items(); |
Collaborator
There was a problem hiding this comment.
Just return
tutor_utils()->count( tutor_get_cart_items() );
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.