Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1130349
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 6 years ago.
Improve this questionIs it possible to retrive woocommerce cart url using javascript or jquery? Are there native functions or do I have to perform an ajax call to retrieve it?
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 6 years ago.
Improve this questionIs it possible to retrive woocommerce cart url using javascript or jquery? Are there native functions or do I have to perform an ajax call to retrieve it?
Share Improve this question asked Jan 10, 2019 at 18:50 Dim13iDim13i 1251 silver badge5 bronze badges1 Answer
Reset to default 0You can pass it to the script via the functions.php file or a plugin using the wp_localize_script function.
<?php
function my_load_scripts() {
wp_enqueue_script('my-script', plugin_dir_url( __FILE__ ) . 'js/my-script.js');
wp_localize_script('my-script', 'my_script_vars', array(
'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) )
)
);
}
add_action('wp_enqueue_scripts', 'my_load_scripts');
Then it will be available in your script ( in the example: my_script_vars.woo_cart_url )
https://pippinsplugins/use-wp_localize_script-it-is-awesome/
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 6 years ago.
Improve this questionIs it possible to retrive woocommerce cart url using javascript or jquery? Are there native functions or do I have to perform an ajax call to retrieve it?
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 6 years ago.
Improve this questionIs it possible to retrive woocommerce cart url using javascript or jquery? Are there native functions or do I have to perform an ajax call to retrieve it?
Share Improve this question asked Jan 10, 2019 at 18:50 Dim13iDim13i 1251 silver badge5 bronze badges1 Answer
Reset to default 0You can pass it to the script via the functions.php file or a plugin using the wp_localize_script function.
<?php
function my_load_scripts() {
wp_enqueue_script('my-script', plugin_dir_url( __FILE__ ) . 'js/my-script.js');
wp_localize_script('my-script', 'my_script_vars', array(
'woo_cart_url' => get_permalink( wc_get_page_id( 'cart' ) )
)
);
}
add_action('wp_enqueue_scripts', 'my_load_scripts');
Then it will be available in your script ( in the example: my_script_vars.woo_cart_url )
https://pippinsplugins/use-wp_localize_script-it-is-awesome/
本文标签: Retrieve Woocommerce Cart Url with javascriptjquery
版权声明:本文标题:Retrieve Woocommerce Cart Url with javascriptjquery 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749022912a2304655.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论