Skip to content

Commit 6dad053

Browse files
authored
Merge pull request #2878 from Codeinwp/fix/woo-builder
Small Woo Builder Fixes
2 parents 19c0077 + 9178fe5 commit 6dad053

11 files changed

Lines changed: 32 additions & 23 deletions

plugins/otter-pro/inc/render/woocommerce/class-product-add-to-cart-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
3432
return;
3533
}
34+
35+
ob_start();
3636
woocommerce_template_single_add_to_cart();
3737
$output = ob_get_clean();
3838
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-images-block.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
@@ -38,6 +36,7 @@ public function render( $attributes ) {
3836
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
3937
}
4038

39+
ob_start();
4140
woocommerce_show_product_images();
4241
woocommerce_show_product_sale_flash();
4342

plugins/otter-pro/inc/render/woocommerce/class-product-meta-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
3432
return;
3533
}
34+
35+
ob_start();
3636
woocommerce_template_single_meta();
3737
$output = ob_get_clean();
3838
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-price-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
3432
return;
3533
}
34+
35+
ob_start();
3636
woocommerce_template_single_price();
3737
$output = ob_get_clean();
3838
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-rating-block.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,21 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
29+
$is_editor_preview = defined( 'REST_REQUEST' ) && REST_REQUEST;
3030

3131
global $product;
3232

3333
if ( ! $product ) {
34-
return;
34+
return $is_editor_preview ? __( 'Your product ratings will display here.', 'otter-pro' ) : '';
3535
}
36+
37+
$show_placeholder = $is_editor_preview || current_user_can( 'edit_post', $product->get_id() );
38+
39+
ob_start();
3640
woocommerce_template_single_rating();
3741
$output = ob_get_clean();
3842

39-
if ( empty( $output ) ) {
43+
if ( empty( $output ) && $show_placeholder ) {
4044
$output = __( 'Your product ratings will display here.', 'otter-pro' );
4145
}
4246
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-related-products-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
3432
return;
3533
}
34+
35+
ob_start();
3636
woocommerce_output_related_products();
3737
$output = ob_get_clean();
3838
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-short-description-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
3432
return;
3533
}
34+
35+
ob_start();
3636
woocommerce_template_single_excerpt();
3737
$output = ob_get_clean();
3838
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-stock-block.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29+
30+
$is_editor_preview = defined( 'REST_REQUEST' ) && REST_REQUEST;
31+
2932
global $product;
3033

3134
if ( ! $product ) {
32-
return;
35+
return $is_editor_preview ? __( 'Your product stock will display here.', 'otter-pro' ) : '';
3336
}
37+
38+
$show_placeholder = $is_editor_preview || current_user_can( 'edit_post', $product->get_id() );
39+
3440
$output = wc_get_stock_html( $product );
3541

36-
if ( empty( $output ) ) {
42+
if ( empty( $output ) && $show_placeholder ) {
3743
$output = __( 'Your product stock will display here.', 'otter-pro' );
3844
}
3945
return $output;

plugins/otter-pro/inc/render/woocommerce/class-product-tabs-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
@@ -42,8 +40,10 @@ function ( $tabs ) {
4240
}
4341
);
4442

43+
ob_start();
4544
woocommerce_output_product_data_tabs();
4645
$output = ob_get_clean();
46+
4747
return $output;
4848
}
4949
}

plugins/otter-pro/inc/render/woocommerce/class-product-title-block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function render( $attributes ) {
2626
return;
2727
}
2828

29-
ob_start();
30-
3129
global $product;
3230

3331
if ( ! $product ) {
3432
return;
3533
}
34+
35+
ob_start();
3636
woocommerce_template_single_title();
3737
$output = ob_get_clean();
3838
return $output;

0 commit comments

Comments
 (0)