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

Commit

Permalink
fix: show sale bage on Product Image Gallery block #8528
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Mar 7, 2023
1 parent 50f6500 commit 6b48d90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { registerBlockSingleProductTemplate } from '@woocommerce/atomic-utils';
*/
import edit from './edit';
import metadata from './block.json';
import './style.scss';

registerBlockSingleProductTemplate( {
registerBlockFn: () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.woocommerce .wp-block-woocommerce-product-image-gallery {
position: relative;

div.images {
width: unset !important;
}

span.onsale {
right: unset;
z-index: 1;
left: -1rem
}
}
6 changes: 5 additions & 1 deletion src/BlockTypes/ProductImageGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ protected function render( $attributes, $content, $block ) {
}

$classname = $attributes['className'] ?? '';
ob_start();
woocommerce_show_product_sale_flash();
$sale_badge_html = ob_get_clean();

ob_start();
woocommerce_show_product_images();
$product_image_gallery_html = ob_get_clean();

return sprintf(
'<div class="wp-block-woocommerce-product-image-gallery %1$s">%2$s</div>',
'<div class="wp-block-woocommerce-product-image-gallery %1$s">%2$s %3$s</div>',
esc_attr( $classname ),
$sale_badge_html,
$product_image_gallery_html
);

Expand Down

0 comments on commit 6b48d90

Please sign in to comment.