Simple Product Permalink in Mini Cart —

This topic has 2 replies, 2 voices, and was last updated 2 months, 1 weeks ago ago by Luca Rossi

  • Avatar: robert@trontz.com
    robert@trontz.com
    Participant
    April 4, 2025 at 21:34

    Hi,

    My site utilizes XStore, Woocommerce and Grouped Simple Products. In the Mini-Cart the Simple Product or product_id is being pulled into the product permalink. Is there a way in the Mini-Cart to get the product Permalink to the Grouped Product or group_id? On the actual Cart page it drops the Product Permalink all together.

    I have tried a few things like to removing the Mini-Cart product permalink to match the cart page or template modification. Nothing seems to be working. Can you help?

    Thanks Rob

    1 Answer
    Avatar: Justin
    Luca Rossi
    Support staff
    April 5, 2025 at 12:05

    Dear Robert,

    Thank you for reaching out to us.

    Please note that implementing the functionality you described would require a significant amount of custom coding.

    1. To determine whether a product is a child of a grouped product, you may use the following code snippet:

    
    $product_id = 123; // The ID of the product you're checking
    
    $args = array(
        'type' => 'grouped',
        'post_type' => 'product',
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'fields' => 'ids',
    );
    
    $grouped_products = wc_get_products($args);
    
    $is_child = false;
    
    foreach ($grouped_products as $grouped_id) {
        $grouped_product = wc_get_product($grouped_id);
        $children = $grouped_product->get_children(); // array of child product IDs
    
        if (in_array($product_id, $children)) {
            $is_child = true;
            break;
        }
    }
    
    if ($is_child) {
        echo "Product #$product_id is a child of a grouped product.";
    } else {
        echo "Product #$product_id is not a child of any grouped product.";
    }
    

    2. Additionally, you can use the woocommerce_cart_item_permalink hook to modify the mini-cart item link based on the result of the above check. More information on this hook can be found here:
    https://wp-kama.com/plugin/woocommerce/hook/woocommerce_cart_item_permalink

    Please be advised that such customizations fall outside the scope of our standard support services.

    If you require further assistance or would like to request a custom solution, we kindly invite you to submit a request through our Customization Panel:
    https://www.8theme.com/account/#etheme_customization_panel

    Please note that customization services may be subject to additional charges.

    We appreciate your understanding and are here to help should you have any further questions.

    Best regards,
    The 8Theme Team

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

Helpful Topics

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.