0

I want to use the "cost of goods" field created by the woocommerce cost of goods plugin when calculating totals on my purchase orders (which are automatically e-mailed) from the woocommerce dropship plugin.

I found the below code in this question by user2389087 for someone who wanted to text order notifications. I'm thinking I can hijack that code with a little tweaking, but I don't know where to put it.

I know the get_items() function is used in creating the order notification e-mails, but I'm not sure what the dropship plugin uses to gather information.

function custom_woocommerce_complete_order_sms( $order_id ) {
        global $woocommerce;
        if ( !$order_id )
        return;
        $order = new WC_Order( $order_id );

        $product_list = '';
        $order_item = $order->get_items();

        foreach( $order_item as $product ) {
            $prodct_name[] = $product['name']; 
        }

        $product_list = implode( ',\n', $prodct_name );
dbc
  • 104,963
  • 20
  • 228
  • 340
  • It's been a while since I wrote that code (2 years I think). However to answer one of your questions, the code is put in the functions.php file. I called it on the woo_commerce thank you hook - add_action( 'woocommerce_thankyou', 'your_function' ); – user2389087 Jul 22 '19 at 21:26
  • also I know nothing about the cost of goods plugin, but I assume it adds a new meta_field to the post meta? If so you'll need to reference that for the order and it should give you what you're looking for. – user2389087 Jul 22 '19 at 21:30

0 Answers0