• Resolved sorro445

    (@sorro445)


    Hi,
    I am using Suki and also Woocommerce and another plugin, Collapseomatic. Now I need Collapseomatic to display a product description accordionlike in the woocommerce cart and checkout table, and it is not working correctly, so I had asked the Collapseomatic support and they told me to ask the theme support

    if they provide a callback on after the checkout items have successfully loaded so other functions can be triggered

    Is this the case?

    Thanks for your help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Theme Author sukiwp

    (@sukiwp)

    Hi @sorro445

    From what I’ve seen, you want to “insert WooCommerce product description into cart table”. And you want the description to be in an accordion style (using Collapseomatic). This is not related to Suki, but we found something that would be helpful for you.

    So the callback that they mention is called “hook” in WordPress terminology. WooCommerce has a hook that allows you to insert the product description into each cart item (maybe after the product name). You would need to do custom coding (via Child Theme or separate plugin) and it would require some PHP knowledge.

    Please refer to these articles:

    https://www.themelocation.com/display-product-short-description-in-woo/

    To use the accordion style from Collapseomatic, you need to change the $post_data->post_excerpt part to be '[expand title="trigger text"]' . $post_data->post_excerpt . '[/expand]'.

    Hope it helps 🙂

    Thread Starter sorro445

    (@sorro445)

    Hi,
    thanks for your help.
    I actually need the product short desccription for something else, that’s why I had created the custom field. But even if I was to use it, your code still has the an issue: If I add this to my child theme

    add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_15127954', 10, 2 );
    function wc_checkout_description_so_15127954( $other_data, $cart_item )
    {
        $post_data = get_post( $cart_item['product_id'] );
        $other_data[] = array( 'name' =>  '[expand title="trigger text"]' . $post_data->post_excerpt . '[/expand]' );
        return $other_data;
    }

    the shortcode gets displayed as plain tect in the cart and checkout tables, with no accordion styling/function.

    Theme Author sukiwp

    (@sukiwp)

    Try to wrap it with do_shortcode

    So it will be: do_shortcode( '[expand title="trigger text"]' . $post_data->post_excerpt . '[/expand]' )

    If you want to display the custom field, you need to change the $post_data->post_excerpt with your custom field.

    Thread Starter sorro445

    (@sorro445)

    Hi,
    this still does not work 100%. First, it adds a “:” to the Expand title, which is not normal and which does not happen when using my original function to display the custom field in the tables:

    add_filter( 'woocommerce_cart_item_name', 'customizing_cart_item_name', 10, 3 );
    function customizing_cart_item_name( $product_name, $cart_item, $cart_item_key ) {
        $product = $cart_item['data']; // Get the WC_Product Object
    
        if ( $value = $product->get_meta('description') ) {
            $product_name .= '<small>'. do_shortcode( $value ) .'</small>';
        }
        return $product_name;
    }

    and when I try to enter my custom field like this

    add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_15127954', 10, 2 );
    function wc_checkout_description_so_15127954( $other_data, $cart_item )
    {
        $post_data = get_post( $cart_item['product_id'] );
        $other_data[] = array( 'name' =>  do_shortcode( '[expand title="Details"]' . $description . '[/expand]' ) );
        return $other_data;
    }
    

    I not only get the “:” but also the accordion does not work…

    Theme Author sukiwp

    (@sukiwp)

    You are using $description while it’s not yet defined anywhere inside the function. Of course, it is a blank variable.

    About the “:”, I think it’s added by default from the plugin. As you can see, we don’t add any “:” in the custom code.

    By the way, this is not a theme issue, I just helped you pointing out how to do it. You might need to browse around WooCommerce documentation to know how to fetch the proper custom field you are using.

    Thread Starter sorro445

    (@sorro445)

    Hi,

    no, Collapseoamtic does not add a “:”, when inserting it with my function or even just in a regular page, ther is no “:”. So it has to do with adding it with the function you had suggested. So overall, the theme does not provide a hook as Collapseomatic was wondering?

    Theme Author sukiwp

    (@sukiwp)

    As I mentioned, this is a question for WooCommerce and Collapseomatic. This has nothing to do with Suki theme at all.

    You can try to remove the Collapseomatic shortcode wrapper. Let see if the “:” is also added. If yes, then it’s automatically added by WooCommerce.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Question backcall’ is closed to new replies.