Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1122832
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 months ago.
Improve this questionI am updating existing payment gateway to support latest version of wordpress and also to make compitable with block-based checkout. I want to display multiple payment option list under my payment gateway but when i use some html in js it throws syntax error. Plese help me as i am new to block-based checkout. below are my js and wordpress code
JS CODE:---
const settings = window.wc.wcSettings.getSetting( 'casheer_data', {} );
const Label = ( props ) => {
const { PaymentMethodLabel } = propsponents
return <PaymentMethodLabel text={ label } /> /* in this line i am getting erro */
}
const Content = () => {
return window.wp.htmlEntities.decodeEntities( settings.description || '' );
};
const Block_Gateway = {
name: 'casheer',
label: <Label />,
content: Object( window.wp.element.createElement )( Content, null ),
edit: Object( window.wp.element.createElement )( Content, null ),
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings.supports
},
};
window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway );
Below is my register script function
wp_register_script(
'casheer-blocks-integration',
plugin_dir_url(__FILE__) . 'checkout.js',
[
'wc-blocks-registry',
'wc-settings',
'wp-components',
'wp-element',
'wp-data',
'wp-html-entities',
'wp-i18n',
],
null,
true
);
if( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( 'casheer-blocks-integration');
}
wp_localize_script( 'casheer-blocks-integration', 'myCustomGatewayData', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
// Other data
));
return [ 'casheer-blocks-integration' ];
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 months ago.
Improve this questionI am updating existing payment gateway to support latest version of wordpress and also to make compitable with block-based checkout. I want to display multiple payment option list under my payment gateway but when i use some html in js it throws syntax error. Plese help me as i am new to block-based checkout. below are my js and wordpress code
JS CODE:---
const settings = window.wc.wcSettings.getSetting( 'casheer_data', {} );
const Label = ( props ) => {
const { PaymentMethodLabel } = props.components
return <PaymentMethodLabel text={ label } /> /* in this line i am getting erro */
}
const Content = () => {
return window.wp.htmlEntities.decodeEntities( settings.description || '' );
};
const Block_Gateway = {
name: 'casheer',
label: <Label />,
content: Object( window.wp.element.createElement )( Content, null ),
edit: Object( window.wp.element.createElement )( Content, null ),
canMakePayment: () => true,
ariaLabel: label,
supports: {
features: settings.supports
},
};
window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway );
Below is my register script function
wp_register_script(
'casheer-blocks-integration',
plugin_dir_url(__FILE__) . 'checkout.js',
[
'wc-blocks-registry',
'wc-settings',
'wp-components',
'wp-element',
'wp-data',
'wp-html-entities',
'wp-i18n',
],
null,
true
);
if( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( 'casheer-blocks-integration');
}
wp_localize_script( 'casheer-blocks-integration', 'myCustomGatewayData', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
// Other data
));
return [ 'casheer-blocks-integration' ];
Share
Improve this question
edited Aug 8, 2024 at 17:34
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Aug 6, 2024 at 6:56
user246843user246843
11 bronze badge
1 Answer
Reset to default 1In this code:
const Label = ( props ) => {
const { PaymentMethodLabel } = props.components
return <PaymentMethodLabel text={ label } /> /* in this line i am getting erro */
}
you use label variable, but it is not defined anywhere. It should be props.label
?
But also, later you are using this like that:
label: <Label />,
So you are not giving any props to this component. So even with above fix, it won't be working.
I recommend to use TypeScript in your project with ESLint it will catch such issues right in your code editor (missing required params, or using undefined variables).
本文标签:
版权声明:本文标题:woocommerce offtopic - Getting Uncaught SyntaxError: Unexpected token '<' when creating block based custo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736298563a1930251.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论