• Resolved fabiengrosieux

    (@fabiengrosieux)


    Hello !

    First we love your plugin, became indispensable for us and our clients. I just have a question, is it possible to fetch the quantity of a specific product from an order ?

    Imagine : I have an order with 3 product : A, B and C
    I want the quantity of the C product, or even better the total price of this product, if it is 10€ and I have 2 in my order, I need to be able to print “20€”.

    Is that possible ?
    Thank you very much !
    Fabien

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi there,

    Thanks for reaching out.

    I have passed your request on to the relevant team. They will get back to you as soon as they can.

    Kind regards,
    Moshtafizur

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @fabiengrosieux,

    Thank you for the feedback ??

    We can solve the task with a small PHP snippet:

    add_shortcode( 'my_alg_wc_custom_emails_item_total', function ( $atts ) {
        if (
            isset( $atts['product_id'] ) &&
            function_exists( 'alg_wc_custom_emails' ) &&
            isset( alg_wc_custom_emails()->core->shortcodes->order )
        ) {
            $order = alg_wc_custom_emails()->core->shortcodes->order;
            foreach ( $order->get_items() as $item ) {
                if ( $atts['product_id'] == $item['product_id'] ) {
                    return wc_price(
                        $item['line_total'],
                        array( 'currency' => $order->get_currency() )
                    );
                }
            }
        }
    } );

    The snippet will add a custom shortcode, which you can then use in the custom email’s “Email content” option, like this:

    [my_alg_wc_custom_emails_item_total product_id="1651"]

    Please give it a try and let me know what you think.

    Thread Starter fabiengrosieux

    (@fabiengrosieux)

    Damn I’m speechless ! Thank you so much ! It works perfectly

    Kind regards,
    Fabien

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @fabiengrosieux,

    Happy to help ?? Let me know if you need anything else.

    And if you like the plugin, please consider leaving me a rating.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get Specific product name from order with its quantity’ is closed to new replies.