Fix Mini Cart missing translations (https://github.com/woocommerce/woocommerce-blocks/pull/8591)
This commit is contained in:
parent
0c4ad5ec13
commit
4b82793b33
|
@ -9,9 +9,11 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/empty-mini-cart-contents-block', {
|
||||
icon: {
|
||||
src: (
|
||||
<Icon
|
||||
|
|
|
@ -9,9 +9,11 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/filled-mini-cart-contents-block', {
|
||||
icon: {
|
||||
src: (
|
||||
<Icon
|
||||
|
|
|
@ -8,10 +8,12 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
import attributes from './attributes';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/mini-cart-footer-block', {
|
||||
icon: {
|
||||
src: (
|
||||
<Icon
|
||||
|
|
|
@ -8,9 +8,11 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/mini-cart-items-block', {
|
||||
icon: {
|
||||
src: (
|
||||
<Icon
|
||||
|
|
|
@ -8,9 +8,11 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/mini-cart-products-table-block', {
|
||||
icon: (
|
||||
<Icon icon={ list } className="wc-block-editor-components-block-icon" />
|
||||
),
|
||||
|
|
|
@ -8,10 +8,12 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
import attributes from './attributes';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/mini-cart-shopping-button-block', {
|
||||
icon: {
|
||||
src: (
|
||||
<Icon
|
||||
|
|
|
@ -8,9 +8,11 @@ import { registerBlockType } from '@wordpress/blocks';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { Edit, Save } from './edit';
|
||||
import metadata from './block.json';
|
||||
|
||||
registerBlockType( metadata, {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore -- TypeScript expects some required properties which we already
|
||||
// registered in PHP.
|
||||
registerBlockType( 'woocommerce/mini-cart-title-block', {
|
||||
icon: {
|
||||
src: (
|
||||
<Icon
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* EmptyMiniCartContentsBlock class.
|
||||
*/
|
||||
class EmptyMiniCartContentsBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'empty-mini-cart-contents-block';
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* FilledMiniCartContentsBlock class.
|
||||
*/
|
||||
class FilledMiniCartContentsBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'filled-mini-cart-contents-block';
|
||||
}
|
|
@ -363,7 +363,6 @@ class MiniCart extends AbstractBlock {
|
|||
$cart_controller = $this->get_cart_controller();
|
||||
$cart = $cart_controller->get_cart_instance();
|
||||
$cart_contents_count = $cart->get_cart_contents_count();
|
||||
$cart_contents = $cart->get_cart();
|
||||
$cart_contents_total = $cart->get_subtotal();
|
||||
|
||||
if ( $cart->display_prices_including_tax() ) {
|
||||
|
@ -378,7 +377,7 @@ class MiniCart extends AbstractBlock {
|
|||
$wrapper_styles = $classes_styles['styles'];
|
||||
|
||||
$aria_label = sprintf(
|
||||
/* translators: %1$d is the number of products in the cart. %2$s is the cart total */
|
||||
/* translators: %1$d is the number of products in the cart. %2$s is the cart total */
|
||||
_n(
|
||||
'%1$d item in cart, total price of %2$s',
|
||||
'%1$d items in cart, total price of %2$s',
|
||||
|
@ -401,7 +400,7 @@ class MiniCart extends AbstractBlock {
|
|||
|
||||
if ( is_cart() || is_checkout() ) {
|
||||
// It is not necessary to load the Mini Cart Block on Cart and Checkout page.
|
||||
return '<div class="' . $wrapper_classes . '" style="visibility:hidden" aria-hidden="true">
|
||||
return '<div class="' . $wrapper_classes . '" style="visibility:hidden" aria-hidden="true">
|
||||
<button class="wc-block-mini-cart__button" aria-label="' . esc_attr( $aria_label ) . '" disabled>' . $button_html . '</button>
|
||||
</div>';
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Package;
|
||||
use Automattic\WooCommerce\Blocks\Assets;
|
||||
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
|
||||
use Automattic\WooCommerce\StoreApi\Utilities\CartController;
|
||||
use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils;
|
||||
|
||||
/**
|
||||
|
@ -140,4 +136,25 @@ class MiniCartContents extends AbstractBlock {
|
|||
$parsed_style
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of Mini Cart block & its inner-block types.
|
||||
*
|
||||
* @return array;
|
||||
*/
|
||||
public static function get_mini_cart_block_types() {
|
||||
$block_types = [];
|
||||
|
||||
$block_types[] = 'MiniCartContents';
|
||||
$block_types[] = 'EmptyMiniCartContentsBlock';
|
||||
$block_types[] = 'FilledMiniCartContentsBlock';
|
||||
$block_types[] = 'MiniCartFooterBlock';
|
||||
$block_types[] = 'MiniCartItemsBlock';
|
||||
$block_types[] = 'MiniCartProductsTableBlock';
|
||||
$block_types[] = 'MiniCartShoppingButtonBlock';
|
||||
$block_types[] = 'MiniCartTitleBlock';
|
||||
|
||||
return $block_types;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* MiniCartFooterBlock class.
|
||||
*/
|
||||
class MiniCartFooterBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'mini-cart-footer-block';
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* MiniCartItemsBlock class.
|
||||
*/
|
||||
class MiniCartItemsBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'mini-cart-items-block';
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* MiniCartProductsTableBlock class.
|
||||
*/
|
||||
class MiniCartProductsTableBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'mini-cart-products-table-block';
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* MiniCartShoppingButtonBlock class.
|
||||
*/
|
||||
class MiniCartShoppingButtonBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'mini-cart-shopping-button-block';
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
namespace Automattic\WooCommerce\Blocks\BlockTypes;
|
||||
|
||||
/**
|
||||
* MiniCartTitleBlock class.
|
||||
*/
|
||||
class MiniCartTitleBlock extends AbstractInnerBlock {
|
||||
/**
|
||||
* Block name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'mini-cart-title-block';
|
||||
}
|
|
@ -8,6 +8,7 @@ use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi;
|
|||
use Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry;
|
||||
use Automattic\WooCommerce\Blocks\BlockTypes\Cart;
|
||||
use Automattic\WooCommerce\Blocks\BlockTypes\Checkout;
|
||||
use Automattic\WooCommerce\Blocks\BlockTypes\MiniCartContents;
|
||||
|
||||
/**
|
||||
* BlockTypesController class.
|
||||
|
@ -182,7 +183,6 @@ final class BlockTypesController {
|
|||
'FilterWrapper',
|
||||
'HandpickedProducts',
|
||||
'MiniCart',
|
||||
'MiniCartContents',
|
||||
'StoreNotices',
|
||||
'PriceFilter',
|
||||
'ProductAddToCart',
|
||||
|
@ -217,7 +217,12 @@ final class BlockTypesController {
|
|||
'StockFilter',
|
||||
];
|
||||
|
||||
$block_types = array_merge( $block_types, Cart::get_cart_block_types(), Checkout::get_checkout_block_types() );
|
||||
$block_types = array_merge(
|
||||
$block_types,
|
||||
Cart::get_cart_block_types(),
|
||||
Checkout::get_checkout_block_types(),
|
||||
MiniCartContents::get_mini_cart_block_types()
|
||||
);
|
||||
|
||||
if ( Package::feature()->is_experimental_build() ) {
|
||||
$block_types[] = 'SingleProduct';
|
||||
|
|
Loading…
Reference in New Issue