Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Fix broken styles for Add to Cart Form block
Browse files Browse the repository at this point in the history
  • Loading branch information
thealexandrelara committed Jul 19, 2023
1 parent 7b8a191 commit 1e60e1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Icon, button } from '@wordpress/icons';
*/
import metadata from './block.json';
import edit from './edit';
import './style.scss';
import './editor.scss';

const blockSettings = {
edit,
Expand Down
2 changes: 2 additions & 0 deletions bin/webpack-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const entries = {
'./assets/js/atomic/blocks/product-elements/product-reviews/index.tsx',
'product-details':
'./assets/js/atomic/blocks/product-elements/product-details/index.tsx',
'add-to-cart-form':
'./assets/js/atomic/blocks/product-elements/add-to-cart-form/index.tsx',
...getBlockEntries( '{index,block,frontend}.{t,j}s{,x}' ),
},
core: {
Expand Down
6 changes: 4 additions & 2 deletions src/BlockTypes/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ protected function render( $attributes, $content, $block ) {

$classname = $attributes['className'] ?? '';
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
$product_classname = $is_descendent_of_single_product_block ? 'product': '';

$form = sprintf(
'<div class="wp-block-add-to-cart-form %1$s %2$s" style="%3$s">%4$s</div>',
'<div class="wp-block-add-to-cart-form %1$s %2$s %3$s" style="%4$s">%5$s</div>',
esc_attr( $classes_and_styles['classes'] ),
esc_attr( $classname ),
esc_attr( $product_classname ),
esc_attr( $classes_and_styles['styles'] ),
$product
);
Expand Down Expand Up @@ -182,7 +184,7 @@ protected function get_block_type_script( $key = null ) {
* @return null
*/
protected function get_block_type_style() {
return null;
return array_merge( parent::get_block_type_style(), [ 'wc-blocks-packages-style' ] );
}

/**
Expand Down

0 comments on commit 1e60e1f

Please sign in to comment.