Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Block Hooks API: Cart and Checkout Integration #46859

Closed
wants to merge 3 commits into from

Conversation

tjcafferkey
Copy link
Contributor

@tjcafferkey tjcafferkey commented Apr 24, 2024

Note: This code should probably be moved to a more relevant part of the codebase. It's currently here just to prove a concept.

Add filter to the_content to allow the hooked blocks algorithm to auto-insert blocks into the cart and checkout pages.

  • Show hooked blocks on the frontend
  • Show hooked blocks within the editor

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes # .

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Add the below code to your store
  2. Check the hooked block renders frontend
  3. Check the hooked block renders editor side
function hooked_loginout_into_cart( $hooked_blocks, $position, $anchor_block, $context ) {
	if ( $anchor_block === 'woocommerce/cart' && $position === 'after' ) {
		$hooked_blocks[] = 'core/loginout';
	}

	return $hooked_blocks;
}

add_filter( 'hooked_block_types', 'hooked_loginout_into_cart', 10, 4 );

function hooked_loginout_into_checkout( $hooked_blocks, $position, $anchor_block, $context ) {
	if ( $anchor_block === 'woocommerce/checkout-contact-information-block' && $position === 'after' ) {
		$hooked_blocks[] = 'core/loginout';
	}

	return $hooked_blocks;
}

add_filter( 'hooked_block_types', 'hooked_loginout_into_checkout', 10, 4 );

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Apr 24, 2024
@tjcafferkey tjcafferkey changed the title Block Hooks API: Cart and Checkout Integration POC: Block Hooks API: Cart and Checkout Integration Apr 24, 2024
@tjcafferkey tjcafferkey closed this Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants