Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Missing the woocommerce_after_shop_loop_item action hook #8261

Closed
wouterch opened this issue Jan 21, 2023 · 1 comment
Closed

Missing the woocommerce_after_shop_loop_item action hook #8261

wouterch opened this issue Jan 21, 2023 · 1 comment
Labels
block-type: product-query Issues related to/affecting all product-query variations. category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. type: enhancement The issue is a request for an enhancement.

Comments

@wouterch
Copy link

wouterch commented Jan 21, 2023

I currenly use the woocommerce_after_shop_loop_item in custom code I have written to display a 'New!' text on category pages for all products that were added in the last 7 days. This suits me perfectly. However, with blocks, this doesn't work.

Is there any workaround to this?

I don't understand how woocommerce_blocks_product_grid_item_html could work instead. Any clear documentation on this? Or wouldn't this be able to help my use case?

I use something like:

function show_new_product_label_on_category_page() {
	global $product; // get global product variable
	$newness_days = 7; // set variable for when something is still new (within these days)
	$created      = strtotime( $product->get_date_created() ); // when was the product created?
	if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) {
		echo '' . esc_html__( 'New!', 'woocommerce' ) . '';
	}
}
@wouterch wouterch added the type: enhancement The issue is a request for an enhancement. label Jan 21, 2023
@Aljullu
Copy link
Contributor

Aljullu commented Jan 23, 2023

Thanks for opening this issue @wouterch!

We are working on a new Products block (woocommerce/woocommerce#42616) which is already available in WC core under the Products (beta) name.

We recently add a compatibility layer so it will support several hooks, including woocommerce_after_shop_loop_item. You can read more about it in this PR: #8172. Support for these hooks will be included in WC Blocks 9.5 (to be released next week) and WC core 7.5 (to be released on March 14th). I would suggest to test your extension with this new block once we release the new compatibility layer.

The plan is that all other product grid blocks will transition to this new Products block, so I will mark this issue as fixed. However, you can still add new comments if you have any questions or would like to add something.

@Aljullu Aljullu closed this as completed Jan 23, 2023
@Aljullu Aljullu added category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. block-type: product-query Issues related to/affecting all product-query variations. labels Jan 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block-type: product-query Issues related to/affecting all product-query variations. category: extensibility Work involving adding or updating extensibility. Useful to combine with other scopes impacted. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants