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

fix: Show sale bage on Product Image Gallery block #8652

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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