Title: Adding custom script after customer submits order
Last modified: April 1, 2017

---

# Adding custom script after customer submits order

 *  [penguana](https://wordpress.org/support/users/penguana/)
 * (@penguana)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-script-after-customer-submits-order/)
 * Hello,
 * I need to have custom script run (to send data to an external API) when a customer
   confirms an order.
 * Currently I have placed it inside class-wc-checkout.php, inside
    `public function
   create_order()` due to time constrains – fix it now, we’ll optimize later.
 * Half is inside
    `foreach (WC()->cart->get_cart() as $cart_item_key => $values)`
   to get ID, quantity and SKU (from database) about each item and if it needs to
   be send to the API (not all items need to be sent). The other half is under the
   function, getting custom field data, if needed, from `$this->posted` (using woocommerce
   checkout manager).
 * It works, but I know it’s bad practice, so my question is:
 * How can I make it as a stand-alone plugin so I don’t have to edit woocommerce
   files?
 * Regards,
    Stelios
    -  This topic was modified 9 years, 2 months ago by [penguana](https://wordpress.org/support/users/penguana/).
    -  This topic was modified 9 years, 2 months ago by [penguana](https://wordpress.org/support/users/penguana/).

Viewing 1 replies (of 1 total)

 *  [Sekander Badsha](https://wordpress.org/support/users/badsha_eee/)
 * (@badsha_eee)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-script-after-customer-submits-order/#post-8980996)
 * Hello Penguana,
 * I am not a developer. So I am not clear what you are trying to do and I don’t
   know what are the best practice.
 * WooCommerce has REST API feature, that might help you.
    Here is the documentation
   [https://docs.woocommerce.com/document/woocommerce-rest-api/](https://docs.woocommerce.com/document/woocommerce-rest-api/)

Viewing 1 replies (of 1 total)

The topic ‘Adding custom script after customer submits order’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [api](https://wordpress.org/support/topic-tag/api/)

 * 1 reply
 * 2 participants
 * Last reply from: [Sekander Badsha](https://wordpress.org/support/users/badsha_eee/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/adding-custom-script-after-customer-submits-order/#post-8980996)
 * Status: not resolved