• Resolved regivanx

    (@regivanx)


    Hello,

    I use the curl woocommerce REST API to create my orders. However, this way of creating orders does not trigger the sending of the invoice by email to the customer. Then I have to send the invoice with the mouse via the wordpress and woocommerce sub-menus.

    How to trigger the sending of the customer-invoice.php invoice email from the command line, by submitting the order number to it? There may be a solution with the REST API or wc-cli…

    Maybe with wp eval-file ? In this case, how to send the arguments to the program?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Since this is a development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    We also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.`

    This thread has been inactive for a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Thread Starter regivanx

    (@regivanx)

    SOLUTION: by default the order status is “pending”, which does not send an email. To send an email, you must put the status “on-hold”.

    Or, via the REST API:

    
    curl -X POST https://example.com/wp-json/wc/v3/orders \
        -u consumer_key:consumer_secret \
        -H "Content-Type: application/json" \
        -d '{
      "payment_method": "bacs",
      "payment_method_title": "Direct Bank Transfer",
      "status": "on-hold"
      "billing": {
        "first_name": "John",
        "last_name": "Doe",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "[email protected]",
        "phone": "(555) 555-5555"
      },
      "shipping": {
        "first_name": "John",
        "last_name": "Doe",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US"
      },
      "line_items": [
        {
          "product_id": 93,
          "quantity": 2
        },
        {
          "product_id": 22,
          "variation_id": 23,
          "quantity": 1
        }
      ],
      "shipping_lines": [
        {
          "method_id": "flat_rate",
          "method_title": "Flat Rate",
          "total": "10.00"
        }
      ]
    }'

    You can do the same with wp-cli, something like:

    
    wp wc shop_order create \
    --customer=5 \
    --status=on-hold \
    --billing='json stuffs' \
    --shipping='other json stuffs' \
    --line_items='yet other json stuffs' \
    --user='NAME'
    
    • This reply was modified 2 years, 7 months ago by regivanx. Reason: format
    • This reply was modified 2 years, 7 months ago by regivanx. Reason: format
    • This reply was modified 2 years, 7 months ago by regivanx. Reason: typo
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to trigger the sending of the invoice by email to the customer by the CLI?’ is closed to new replies.