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 (#8652)
Browse files Browse the repository at this point in the history
* fix: show sale bage on Product Image Gallery block #8528

* set multiple flag to false
  • Loading branch information
gigitux authored Mar 9, 2023
1 parent 0fdb926 commit 01efca1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"category": "woocommerce",
"supports": {
"align": true,
"reusable": false
"multiple": false
},
"keywords": [ "WooCommerce" ],
"usesContext": [ "postId", "postType", "queryId" ],
Expand Down
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 01efca1

Please sign in to comment.