John Davidson

php - Display related products using a shortcode on WooCommerce My account Dashboard

0 comments
Message:


I'm trying to display related products in My account Dashboard page. I followed this WooCommerce Shortcodes documentation.


I tried to use the following code:


add_action( 'woocommerce_account_content', 'output_shortcode_on_child_pages');
function output_shortcode_on_child_pages() {
$post = get_post();

if ( is_page() AND $post->post_parent ) {
echo do_shortcode( '[related_products limit=”3″]' );
}
}

This does not display the related products. But when I try to display products in specific category like following, it works:


add_action( 'woocommerce_account_content', 'output_shortcode_on_child_pages');
function output_shortcode_on_child_pages() {
$post = get_post();

if ( is_page() AND $post->post_parent ) {
echo do_shortcode( '[products limit="3" columns="3" orderby="rand" category=”presets-and-actions” ]' );
}
}

Kindly any help to resolve this?



My Answer:
>post_parent == get_option( 'woocommerce_myaccount_page_id' ) ) {_ echo do_shortcode('[related_products]');_ }_}_However, this code is not working as expected. Can you please help me to display related products using a shortcode on the WooCommerce My account Dashboard page?

Rate this post

4 of 5 based on 4081 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us