Accordion
1 year ago
AddToCartWithOptions
1 week ago
OrderConfirmation
2 months ago
ProductCollection
3 weeks ago
Reviews
2 months ago
AbstractBlock.php
4 weeks ago
AbstractDynamicBlock.php
2 years ago
AbstractInnerBlock.php
1 year ago
AbstractProductGrid.php
3 months ago
ActiveFilters.php
2 years ago
AddToCartForm.php
4 weeks ago
AddToWishlistButton.php
4 weeks ago
AllProducts.php
2 years ago
AllReviews.php
2 years ago
AtomicBlock.php
2 years ago
AttributeFilter.php
1 year ago
Breadcrumbs.php
1 year ago
Cart.php
2 months ago
CartAcceptedPaymentMethodsBlock.php
2 years ago
CartCrossSellsBlock.php
2 years ago
CartCrossSellsProductsBlock.php
2 years ago
CartExpressPaymentBlock.php
1 year ago
CartItemsBlock.php
2 years ago
CartLineItemsBlock.php
2 years ago
CartLink.php
2 months ago
CartOrderSummaryBlock.php
2 years ago
CartOrderSummaryCouponFormBlock.php
2 years ago
CartOrderSummaryDiscountBlock.php
2 years ago
CartOrderSummaryFeeBlock.php
2 years ago
CartOrderSummaryHeadingBlock.php
2 years ago
CartOrderSummaryShippingBlock.php
2 years ago
CartOrderSummarySubtotalBlock.php
2 years ago
CartOrderSummaryTaxesBlock.php
2 years ago
CartOrderSummaryTotalsBlock.php
2 years ago
CartTotalsBlock.php
2 years ago
CatalogSorting.php
4 weeks ago
CategoryDescription.php
2 months ago
CategoryTitle.php
2 months ago
Checkout.php
2 months ago
CheckoutActionsBlock.php
1 year ago
CheckoutAdditionalInformationBlock.php
2 years ago
CheckoutBillingAddressBlock.php
2 years ago
CheckoutContactInformationBlock.php
2 years ago
CheckoutExpressPaymentBlock.php
9 months ago
CheckoutFieldsBlock.php
2 years ago
CheckoutOrderNoteBlock.php
2 years ago
CheckoutOrderSummaryBlock.php
2 years ago
CheckoutOrderSummaryCartItemsBlock.php
2 years ago
CheckoutOrderSummaryCouponFormBlock.php
2 years ago
CheckoutOrderSummaryDiscountBlock.php
2 years ago
CheckoutOrderSummaryFeeBlock.php
2 years ago
CheckoutOrderSummaryShippingBlock.php
2 years ago
CheckoutOrderSummarySubtotalBlock.php
2 years ago
CheckoutOrderSummaryTaxesBlock.php
2 years ago
CheckoutOrderSummaryTotalsBlock.php
2 years ago
CheckoutPaymentBlock.php
2 years ago
CheckoutPickupOptionsBlock.php
2 years ago
CheckoutShippingAddressBlock.php
2 years ago
CheckoutShippingMethodBlock.php
2 years ago
CheckoutShippingMethodsBlock.php
2 years ago
CheckoutTermsBlock.php
2 years ago
CheckoutTotalsBlock.php
2 years ago
ClassicShortcode.php
1 year ago
ClassicTemplate.php
4 months ago
ComingSoon.php
1 year ago
CouponCode.php
2 months ago
CustomerAccount.php
3 months ago
Dropdown.php
4 weeks ago
EmailContent.php
5 months ago
EmptyCartBlock.php
2 years ago
EmptyMiniCartContentsBlock.php
11 months ago
EnableBlockJsonAssetsTrait.php
1 year ago
FeaturedCategory.php
7 months ago
FeaturedItem.php
7 months ago
FeaturedProduct.php
7 months ago
FilledCartBlock.php
2 years ago
FilledMiniCartContentsBlock.php
4 months ago
FilterWrapper.php
2 years ago
HandpickedProducts.php
1 year ago
MiniCart.php
4 weeks ago
MiniCartCartButtonBlock.php
11 months ago
MiniCartCheckoutButtonBlock.php
11 months ago
MiniCartContents.php
3 months ago
MiniCartFooterBlock.php
4 weeks ago
MiniCartItemsBlock.php
11 months ago
MiniCartProductsTableBlock.php
4 weeks ago
MiniCartShoppingButtonBlock.php
9 months ago
MiniCartTitleBlock.php
11 months ago
MiniCartTitleItemsCounterBlock.php
11 months ago
MiniCartTitleLabelBlock.php
11 months ago
NextPreviousButtons.php
5 months ago
PageContentWrapper.php
2 years ago
PaymentMethodIcons.php
11 months ago
PriceFilter.php
1 year ago
ProceedToCheckoutBlock.php
2 years ago
ProductAverageRating.php
1 year ago
ProductBestSellers.php
2 years ago
ProductButton.php
2 months ago
ProductCategories.php
4 weeks ago
ProductCategory.php
2 years ago
ProductDescription.php
9 months ago
ProductDetails.php
5 months ago
ProductFilterActive.php
4 weeks ago
ProductFilterAttribute.php
4 weeks ago
ProductFilterCheckboxList.php
4 weeks ago
ProductFilterChips.php
4 weeks ago
ProductFilterClearButton.php
4 weeks ago
ProductFilterPrice.php
4 weeks ago
ProductFilterPriceSlider.php
4 weeks ago
ProductFilterRating.php
4 weeks ago
ProductFilterRemovableChips.php
4 weeks ago
ProductFilterStatus.php
4 weeks ago
ProductFilterTaxonomy.php
4 weeks ago
ProductFilters.php
3 weeks ago
ProductGallery.php
4 weeks ago
ProductGalleryLargeImage.php
4 weeks ago
ProductGalleryThumbnails.php
4 weeks ago
ProductImage.php
4 weeks ago
ProductImageGallery.php
7 months ago
ProductMeta.php
1 year ago
ProductNew.php
2 years ago
ProductOnSale.php
2 years ago
ProductPrice.php
2 months ago
ProductQuery.php
4 weeks ago
ProductRating.php
1 year ago
ProductRatingCounter.php
1 year ago
ProductRatingStars.php
1 year ago
ProductResultsCount.php
2 months ago
ProductSKU.php
2 months ago
ProductSaleBadge.php
1 year ago
ProductSearch.php
10 months ago
ProductSpecifications.php
2 months ago
ProductStockIndicator.php
2 months ago
ProductSummary.php
7 months ago
ProductTag.php
2 years ago
ProductTemplate.php
2 months ago
ProductTitle.php
1 year ago
ProductTopRated.php
2 years ago
ProductsByAttribute.php
2 years ago
RatingFilter.php
2 years ago
RelatedProducts.php
3 months ago
ReviewsByCategory.php
2 years ago
ReviewsByProduct.php
2 years ago
SavedForLater.php
4 weeks ago
SingleProduct.php
2 months ago
StockFilter.php
2 years ago
StoreNotices.php
1 year ago
Wishlist.php
4 weeks ago
FilledMiniCartContentsBlock.php
111 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\Blocks\BlockTypes; |
| 3 | |
| 4 | use Automattic\WooCommerce\Admin\Features\Features; |
| 5 | use Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; |
| 6 | |
| 7 | /** |
| 8 | * FilledMiniCartContentsBlock class. |
| 9 | */ |
| 10 | class FilledMiniCartContentsBlock extends AbstractInnerBlock { |
| 11 | /** |
| 12 | * Block name. |
| 13 | * |
| 14 | * @var string |
| 15 | */ |
| 16 | protected $block_name = 'filled-mini-cart-contents-block'; |
| 17 | |
| 18 | /** |
| 19 | * Render the markup for the Filled Mini-Cart Contents block. |
| 20 | * |
| 21 | * @param array $attributes Block attributes. |
| 22 | * @param string $content Block content. |
| 23 | * @param WP_Block $block Block instance. |
| 24 | * @return string Rendered block type output. |
| 25 | */ |
| 26 | protected function render( $attributes, $content, $block ) { |
| 27 | if ( Features::is_enabled( 'experimental-iapi-mini-cart' ) ) { |
| 28 | return $this->render_experimental_filled_mini_cart_contents( $attributes, $content, $block ); |
| 29 | } |
| 30 | |
| 31 | return $content; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Render the experimental interactivity API powered Filled Mini-Cart Contents block. |
| 36 | * |
| 37 | * @param array $attributes Block attributes. |
| 38 | * @param string $content Block content. |
| 39 | * @param WP_Block $block Block instance. |
| 40 | * @return string Rendered block type output. |
| 41 | */ |
| 42 | protected function render_experimental_filled_mini_cart_contents( $attributes, $content, $block ) { |
| 43 | $consent = 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WooCommerce'; |
| 44 | $notices = BlocksSharedState::get_cart_error_notices( $consent ); |
| 45 | |
| 46 | $context = wp_json_encode( |
| 47 | array( |
| 48 | 'notices' => $notices, |
| 49 | ), |
| 50 | JSON_NUMERIC_CHECK |
| 51 | | JSON_HEX_TAG |
| 52 | | JSON_HEX_APOS |
| 53 | | JSON_HEX_QUOT |
| 54 | | JSON_HEX_AMP |
| 55 | ); |
| 56 | |
| 57 | $wrapper_attributes = get_block_wrapper_attributes( |
| 58 | array( |
| 59 | 'data-wp-interactive' => 'woocommerce/mini-cart', |
| 60 | 'data-wp-context' => 'woocommerce/store-notices::' . $context, |
| 61 | 'data-wp-bind--hidden' => 'state.cartIsEmpty', |
| 62 | ) |
| 63 | ); |
| 64 | |
| 65 | $dismiss_aria_label = __( 'Dismiss this notice', 'woocommerce' ); |
| 66 | |
| 67 | ob_start(); |
| 68 | ?> |
| 69 | <div <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| 70 | <div |
| 71 | class="wc-block-components-notices" |
| 72 | data-wp-interactive="woocommerce/store-notices" |
| 73 | ><template |
| 74 | data-wp-each--notice="context.notices" |
| 75 | data-wp-each-key="context.notice.id" |
| 76 | > |
| 77 | <div |
| 78 | class="wc-block-components-notice-banner" |
| 79 | data-wp-class--is-error="state.isError" |
| 80 | data-wp-class--is-success="state.isSuccess" |
| 81 | data-wp-class--is-info="state.isInfo" |
| 82 | data-wp-class--is-dismissible="context.notice.dismissible" |
| 83 | data-wp-bind--role="state.role" |
| 84 | data-wp-watch="callbacks.injectIcon" |
| 85 | > |
| 86 | <div class="wc-block-components-notice-banner__content"> |
| 87 | <span data-wp-init="callbacks.renderNoticeContent"></span> |
| 88 | </div> |
| 89 | <button |
| 90 | data-wp-bind--hidden="!context.notice.dismissible" |
| 91 | class="wc-block-components-button wp-element-button wc-block-components-notice-banner__dismiss contained" |
| 92 | aria-label="<?php echo esc_attr( $dismiss_aria_label ); ?>" |
| 93 | data-wp-on--click="actions.removeNotice" |
| 94 | > |
| 95 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> |
| 96 | <path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z" /> |
| 97 | </svg> |
| 98 | </button> |
| 99 | </div> |
| 100 | </template> |
| 101 | </div> |
| 102 | <?php |
| 103 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 104 | echo $content; |
| 105 | ?> |
| 106 | </div> |
| 107 | <?php |
| 108 | return ob_get_clean(); |
| 109 | } |
| 110 | } |
| 111 |