Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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

    Yes, i’m able to reproduce the issue.

    See the URL: https://en.sylvainrousselot.net/documents/measurement-and-crises-of-capital/

    And the screenshot: https://en.sylvainrousselot.net/wp-content/uploads/sites/6/2022/02/jetpack_svg_001.png

    I use this extension for svg support.

    Workaround: serve svg from another domain, or from another subdomain (in the case of a network).

    Thread Starter regivanx

    (@regivanx)

    ALTERNATIVE SOLUTION

    You can manage orders by accessing the WordPress REST API via curl and https (among others).

    Follow the instructions to create your REST API keys

    Save your keys in a secure space.

    NOTE: if you use your keys in your shell, they will be saved in your shell history.

    Follow the instructions to manage your orders.

    You have examples on the right.

    A very simple example:

    curl -X POST https://exemple.com/wp-json/wc/v3/orders \
    	     -u ck_baeg3ohr…:cs_outh0Oos… \
    	     -H "Content-Type: application/json" \
    	     -d '{
    		     "customer_id": 2,
    		     "line_items": [
    		     {
    			     "product_id": 1202,
    			     "quantity": 1
    		     }
    		     ]
    	     }'

    You can save your command lines in shell scripts to reuse them later.

    However, I still cannot send an order confirmation email to the customer at the moment. The documentation seems silent on this.

    Thread Starter regivanx

    (@regivanx)

    Some exemples of command lines to create, view, update and delete an order:

    wp wc shop_order create --user=my-login --customer_id=2 --line_items='[{"product_id":1201}]'
    Success: Created shop_order 6428.
    wp wc shop_order get 6428 --user=my-login
    [The table of the order…]
    wp wc shop_order get 6428 --user=my-login --field=line_items | sed '{ s/{/{\n\t/g ; s/}/\n}/g ; s/\(,"\)/,\n\t"/g }'
    [Only the "line_items" field, formated with sed. See the "id" field, not the "product_id" field. Suppose it is: 376.]
    wp wc shop_order update 6428 --user=my-login --customer_id=2 --line_items='[{"id":376,"quantity":2},{"product_id":1202}]'
    [update the quantity of the 376 item and add a new product 1202. You can see the result with:]
    wp wc shop_order get 6428 --user=my-login --field=line_items | sed '{ s/{/{\n\t/g ; s/}/\n}/g ; s/\(,"\)/,\n\t"/g }'
    wp wc shop_order delete 6428 --user=my-login
    [move the order to trash]
    wp help wc shop_order
    [the help]

    NOTA: these commands only manage the orders, but don’t send email. Probably I need a new command to send the purchase order to the customer. If you know the solution, please post it, if not, I will probably open a new topic on this.

    In any case, the main subject of this thread is resolved, I mark it.

    • This reply was modified 3 years, 6 months ago by regivanx.
    Thread Starter regivanx

    (@regivanx)

    Thank you for the documentation!

    The correct syntax is in the FAQ of your doc:

    Some ‘lists’ are objects, for example, if you want to set categories for a product the REST API expects an array of objects: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties

    So to set this you would use JSON like this:

    wp wc product create --name='Product Name' --categories='[ { "id" : 21 } ]' --user=admin

    I do some tests before mark the thread “resolved”.

    • This reply was modified 3 years, 6 months ago by regivanx.
    Thread Starter regivanx

    (@regivanx)

    Hi! I subscribed to both groups.

    Some documentation to be deepened:

Viewing 6 replies - 1 through 6 (of 6 total)