8 – Display Block to retrieve information from Order Item’s Product Variant and display rating & review inside product page

I am working on an e-commerce website development. I have the conventional Products -> Product Variants which goes through Order and payment gateway workflow. However, there is something different in this conventional scenario.

I have setup Product -> Product Variation to categorise the different type of fabrics which fall under a same style.

We have different kinds of fabric which we source from vendors in lots. It so happens that we do not get the same colour, pattern every time and so our Product and Product Variant will be obsolete once we have exhausted the stock.

For this reason, I have setup Taxonomy as per the product classification in our case and I am tagging each product variant with appropriate taxonomy.

This is my Taxonomy hierarchy for example:

enter image description here

And I have made provision to tag this Taxonomy to my Product Variant and this is how it looks:

enter image description here

Now, I would want the user to leave a rating and review for the Product variant after he/she places an order with us. I have added FiveStar rating module and jEditable modules (this is used to edit the field by user in display mode) so that user will be able to Rate and add a Review in “Order Item” as I want the user to be able to rate and review each line item which he/she buys from us. This is how it looks:

enter image description here

It’s all fine until now. But now I want to create a Block which will be placed below the product variant selected by user and it should do the following:

  1. Place a block below in the Product Variation Page.
  2. Fetch all Order Items (within Orders) placed by all users for the same taxonomy which is being shown in the Product Variant Page.
  3. Display the User Name, User profile picture, rating and review left by the user from the above fetched order item which contains the same taxonomy information.

enter image description here

I seem to be completely lost in this last step of fetching ratings & reviews by users on previously placed orders on the same taxonomy as the product variation which is being viewed by the user currently. I have tried to see if there is a module which I am trying to achieve but could not find any. Also tried to see how I can build blocks to achieve this but I seem to be lost. Do I need to do some custom coding to achieve this or is it possible to fetch this relationship somehow? Am I missing something?

Thanks!

Find if widget block is active

I’m used to check if a widget from installed my plugin is active.

With the new block editor extending to widgets in WordPress 5.8, I was wondering if there is a way to check the widget block that I created (both old php-based and gutenberg-based widgets are installed by my plugin) is activated by the user.

Thanks!

WordPress post using block editor displays error when adding the string “cmd.exe”

Today a member of our content team reported that when they attempted to save a post in block editor mode, they continually received an error.

Updating failed. The response is not a valid JSON response.

After some debugging steps we determined that the string “cmd.exe” was to blame. When that string was present the author always got the above error. But when the string was gone or had a space after the “.”, the post saved and displayed just fine. I recreated it in a brand new post, with only the string “cmd.exe” and confirmed that I got the same error.

enter image description here

When viewing the post in the “code editor” view, this is the contents:

<!-- wp:paragraph -->
<p>cmd.exe</p>
<!-- /wp:paragraph -->

We’re currently running WP 5.7.2 on WP Engine.

Does anyone know why this might be happening? I understand it’s probably a security issue, but this seems quite the ham-fisted approach.

Has blocks gutenberg block multiples registers type in my Plugin

I created a plugin that contains multiple blocks and I want it to load assets only if I have one of those blocks created.

Is there any way to get all blocks registered by my plugin?

The idea with this is to use has_block passing the name of the block as a parameter, however, the has_block function will only accept a specific one and not an array

magento2 – Promotional content block on the cart which changes by customer segment

A merchant would like a promotional content block on the cart which changes by customer segment. the
content should only appear when you cart total is $50 or more excluding shipping

What solution will meet the requirement?

  1. Create a widget with a static block assign to a customer price rule.

2]Create a dynamic block and choose the customer segment

3]Create a static block and add it to the layout area for the shopping cart with the customer segment

4]Create a banner, apply the ‘customer segment to the banner and choose the banner price rule

transactions – Bitcoin in RegTest throw (bad-cb-height) at block No. 500

the problem is an incorrect implementation of BIP-0034 in my code, I thought the length of height should be at least 3 bytes which I was wrong,

“Coding Enthusiast” says :
“The block height has to be pushed with the minimal number of bytes:
Since BIP-34 activates at block 500 on RegTest, this is ignored on all blocks from height 1 to 499 and from block height 500 it starts being enforced and the invalid push is rejected.”

the description of the answer is here: bitcointalk.org/index.php?topic=5293244.0

Block Controls not showing – WordPress Development Stack Exchange

I’m building my first Gutenberg block and the problem that I have is that the block control toolbar doesn’t show.
I’ve spend hours comparing my code with other Gutenberg blocks, but couldn’t find what is wrong in my code.
I would highly appreciate if someone could look at my code and advice.

Here is my code:

import { registerBlockType } from '@wordpress/blocks';
import { 
    RichText,
    InspectorControls,
    ColorPalette,
    MediaUpload
        } from '@wordpress/block-editor';
import { 
    PanelBody,
    IconButton } from '@wordpress/components';
 
registerBlockType( 'luxworx-blocks/author-block', {
    apiVersion: 2,
    title: 'Luxworx: Author Block',
    icon: 'universal-access-alt',
    category: 'design',
    example: {},
    attributes: {
        title: {
            type: 'string',
            source: 'html',
            selector: 'h2'
        },
        body: {
            type: 'string',
            source: 'html',
            selector: 'p'
        },
        textColor: {
            type: 'string',
            default: 'black'
        },
        bgColor: {
            type: 'string',
            default: 'white'
        },
        authorImage: {
            type: 'string',
            default: null
        }
    },

    edit( {attributes, setAttributes}) {

        // Custom functions
        function updateTitle (newTitle) {
            setAttributes( { title: newTitle}) 
        }
        function updateBody (newBody) {
            setAttributes( { body: newBody}) 
        }
        function onTextColorChange (newColor) {
            setAttributes( {textColor: newColor})
        }
        function onBgColorChange (newColor2) {
            setAttributes( {bgColor: newColor2})
        }
        function onSelectImage(newImage) {
            setAttributes( {authorImage: newImage.sizes.full.url })
        }
 
        return (
            <InspectorControls key="lx-authors-block-setting" style={ { marginBottom:'40px'} }>
                <PanelBody title={ 'Color setting' }>
                    <p><strong>Select text color:</strong></p>
                    <ColorPalette value={ attributes.textColor }
                                    onChange={ onTextColorChange } />
                    <p><strong>Select block bacground color:</strong></p>
                    <ColorPalette value={ attributes.bgColor }
                                    onChange={ onBgColorChange } />
                </PanelBody>
                <PanelBody title={ 'Author image'}>
                    <p><strong>Select author image:</strong></p>
                    <MediaUpload
                        onSelect={ onSelectImage }
                        type="image"
                        value={ attributes.authorImage }
                        render={ ( { open } ) => (
                            <IconButton
                                onClick={ open }
                                icon="upload"
                                className="editor-media-placeholder__button button is-default">
                                Author Image
                            </IconButton>
                        ) } />
                        
                </PanelBody>
            </InspectorControls>,
            <div className="lx-authors-block wp-block" key="container" style={{ backgroundColor: attributes.bgColor}}>
                <img src={ attributes.authorImage} className="lx-authors-image" />
                <div className="lx-author-info">
                    <RichText   
                                placeholder="Authors name"
                                tagName="h2"
                                value={attributes.title}
                                onChange={updateTitle}
                                style={ {color: attributes.textColor }} />
                    
                    <RichText  
                                placeholder="Authors bio"
                                tagName="p"
                                value={attributes.body}
                                onChange={updateBody}
                                style={ {color:attributes.textColor}} />
                </div>
            </div> 
        );
    },
    save( {attributes}) {
        
        return (
            <div className="lx-authors-block wp-block" style={{ backgroundColor: attributes.bgColor }}>
                <img src={ attributes.authorImage} className="lx-authors-image" />
                <div className="lx-author-info">
                    <h2 style={ { color: attributes.textColor }}>{attributes.title}</h2>
                    <RichText.Content tagName="p"
                                    value={attributes.body}
                                    style={ {color:attributes.textColor}}
                                    />
                </div>
            </div>
        );
    },
} );

How to block the IP that requests excessive 404 page not found

On my site often I see thousands of requests thats ends up 404 – page not found error.
How can I block the IP that exceeds more than certain number of requests within a span of time from drupal. Any help would be appreciated. Thanks

enter image description here

block header – How strict are the unix epoch time validation rules?

I think you have a misconception about what this clause means:

Full nodes will not accept blocks with headers more than two hours in the future according to their clock.

You appear to be interpreting this as, if a new block is more than two hours later than the previous block, then do not accept it. That is incorrect. This clause is not about gaps in time between blocks.

The actual meaning of this clause is that, if a new block says it’s literally from the future, from a time that the universe has not yet reached, then do not accept it. This clause is about preventing manipulation of the blockchain via falsified timestamps.

This comparison is between the new block’s timestamp and your clock, not the new block’s timestamp and the previous block’s timestamp.

bitcoin core – How would I ever know if my solo miner found a block?

I’ve tried solo mining in two ways:

  • using cgminer, ASIC and ckpool
  • using minerd connected to my own instance of bitcoin-qt.

Either way, I’ve never seen any indicator showing that I have mined 0 BTC, let alone > 0. What would it look like if I did beat the odds and mine some BTC?