NO BUG: Two issues in code element inside query loop

Browser: Chrome 133.0.6943.142
OS: Windows

Hi bricks team,

1- I am using this code to display product rating as a round value in the code element.

<?php echo round(floatval("{woo_product_rating:value}"), 1); ?>

In the builder, if a product has no rating value, the value 0 is returned, which is as expected. However, in the frontend, the 0 is not displayed and the value is empty.

2- The code element configuration is as shown below.

The svg icon size is smaller than it should be. Because the code element has a width of 100%. However, enabling “Render without wrapper” solves the problem on the front end.
Although this is not a fatal problem, it makes us see a more accurate result in the frontend instead of the builder. Technically, if the default width of the code element is auto, will it be a problem?

Thank you

Hi @HOSEIN,

I can’t reproduce the issue #1. Can you try without that floatval, because you don’t need to wrap dynamic tags to the quotes.

<?php echo round({woo_product_rating:value}, 1); ?>

For #2 issue, can you copy-paste your “Rating” block, so I can check it locally? But, if the width auto solves it, then you can set it like this :slight_smile:

Thanks,
Matej

Hi @Matej,

Thank you for reviewing this report.

1- I checked your code. like code I was using before, if we enable “Render without wrapper”, it does not return 0 for empty values. An error is also displayed.

2- Yes, sure.

{"content":[{"id":"udpibp","name":"div","parent":"5c1b6b","children":["mqioqy","yegzlb"],"settings":{"_direction":"row","_columnGap":"5"},"label":"Rating"},{"id":"mqioqy","name":"icon","parent":"udpibp","children":[],"settings":{"icon":{"library":"svg","svg":{"id":1840,"filename":"star-bold.svg","url":"https://avangtheme.ir/wp-content/uploads/2025/02/star-bold.svg"},"fill":{"hex":"#ffcc00","id":"bngoja","name":"Main color"}}},"themeStyles":{}},{"id":"yegzlb","name":"code","parent":"udpibp","children":[],"settings":{"code":"<?php echo round({woo_product_rating:value}, 1); ?>","executeCode":true,"signature":"fe2bc919ffae17ecacd8dba42d747694","user_id":1,"time":1741024214,"parseDynamicData":true},"themeStyles":{}}],"source":"bricksCopiedElements","sourceUrl":"https://avangtheme.ir","version":"1.12.2","globalClasses":[],"globalElements":[]}

But, if the width auto solves it, then you can set it like this :slight_smile:

Yes, I’m doing the same thing now. But it produces duplicate CSS.

Thank you

Hi @Matej,

Sorry for tagging. I wanted to remind you of my answer🙏

Hi @HOSEIN,

yeah, it’s ok that you tagged. Sometimes we miss some topics (not intentionally), and it’s nice that you remind us :slight_smile:

For #1, it’s because we added the ability to have dynamic tags inside the PHP code. Now, the code in question is obviously not valid PHP, but because we replace the dynamic tag wit the value, it works.
Sadly, there is no simple/error proof way for us disable this error when using PHP code. So, your best bet is if you ignore it.

For #2: I’m still not sure. That’s the result in my case.

For me, the icon (above number 4), is the correct size?

Best regards,
Matej

1 Like

Thank you Matej,

In your screenshot, it looks like the flex direction is set to vertical and there will definitely be no problem. Please watch the video below. When the layout is the parent of the div, since the width of the div is auto by default, it will affect the size of the SVG icon. Of course, I’m not sure if there’s a problem here or if this is normal behavior.

Please watch the video below.

Hi @HOSEIN,

thank you. You are right, I should have set the other direction. I just copy-pasted you example. :slight_smile:
But, even changing direction and few other settings - I can’t reproduce the same behaviour that you see. I probably have some other styling applied or different wrapper element. Who knows.

But, from the video you shared - I would say that this is not a bug. It’s just different styling that we apply for block and div, which can cause this.

Most of the time, you will set size for the SVG anyway, so this should not make a difference.

Best regards,
Matej

1 Like

Hi @Matej,

Yes, you are right. thanks for reviewing this report🙏

1 Like