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

Commit

Permalink
Add to Cart with Options: Fix styles that are not being applied corre…
Browse files Browse the repository at this point in the history
…ctly (#9472)

* Add missing WooCommerce styles to Add to Cart with Options block

* Fix input style for Add to Cart with Options block

* Add comment about the input-text css class that was added to the Add To Cart Form
  • Loading branch information
thealexandrelara authored May 18, 2023
1 parent 6b6c18f commit 49f5d71
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
font-size: var(--wp--preset--font-size--large);
}
width: unset;

/**
* This is a base style for the input text element in WooCommerce that prevents inputs from appearing too small.
*
* @link https://github.com/woocommerce/woocommerce/blob/95ca53675f2817753d484583c96ca9ab9f725172/plugins/woocommerce/client/legacy/css/woocommerce-blocktheme.scss#L203-L206
*/
.input-text {
font-size: var(--wp--preset--font-size--small);
padding: 0.9rem 1.1rem;
}
}
2 changes: 1 addition & 1 deletion src/BlockTypes/AddToCartForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function render( $attributes, $content, $block ) {
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );

return 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 product %1$s %2$s" style="%3$s">%4$s</div>',
esc_attr( $classes_and_styles['classes'] ),
esc_attr( $classname ),
esc_attr( $classes_and_styles['styles'] ),
Expand Down
2 changes: 1 addition & 1 deletion src/BlockTypes/SingleProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function initialize() {
*/
protected function render( $attributes, $content, $block ) {
$classname = $attributes['className'] ?? '';
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classname ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( sprintf( 'woocommerce %1$s', $classname ) ) ) );

$html = sprintf(
'<div %1$s>
Expand Down

0 comments on commit 49f5d71

Please sign in to comment.