admin管理员组文章数量:1122846
I’m trying to implement a frontend WC block hook, but unfortunately I’m not able to trigger it. I’m using a fresh 8.7.0 install, and blocks are definitely enabled. I’ve tried following the instructions for @wordpress/hooks to either use the defaultHooks.addAction or create a custom object (myObj.hooks.addAction) but I can’t get any WC block events to register with my functions. Here’s an example:
import { createHooks } from "@wordpress/hooks";
let example = {}
example.hooks = createHooks();
example.hooks.addAction(
"experimental__woocommerce_blocks-cart-add-item",
"getverdict/real-id/item-added",
() => {
console.debug("WC :: cart item added");
debugger;
},
1
);
But the listener never fires.
I’ve also tried:
import { defaultHooks } from "@wordpress/hooks";
defaultHooks.addAction(
"experimental__woocommerce_blocks-cart-add-item",
"getverdict/real-id/item-added",
() => {
console.debug("WC :: cart item added");
debugger;
},
1
);
But when I add an item to the cart, the function doesn’t fire. Anyone else using these JS hooks?
As another test, I've tried listening to the all
event, but also no luck.
Any help would be appreciated.
本文标签: block editorUnable to trigger a frontend wordpresshooks action
版权声明:本文标题:block editor - Unable to trigger a frontend @wordpresshooks action 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310573a1934426.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论