Skip to content

Instantly share code, notes, and snippets.

@sftsk
Last active December 2, 2020 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sftsk/037bd885106f34eec2525bf115ff4aac to your computer and use it in GitHub Desktop.
Save sftsk/037bd885106f34eec2525bf115ff4aac to your computer and use it in GitHub Desktop.
WooCommerce <-> Business Central Connector

WooCommerce <-> Business Central Connector

General Setup Connector

  • Custom WordPress/ WooCommerce Plugin + Custom Business Central Extension
  • Items/ Customers gets synced whenever changes within ERP
    • Status page within WooCommerce to see what needs to be synced + log
  • Customers log into WooCommerce, through customer number they are connected with their ERP customer
    • When they log in an offer gets created in the ERP (though an API in real time), through that they are getting their net prices with all discounts etc. (website first shows list prices and then loads net prices through ajax call)
    • As they put items into the cart, they get get added to the offer
    • Delivery addresses/ shipping can be selected but comes from ERP; If new address it can be added manually
    • On checkout offer gets transformed into an order and will be checked from sales team internally
  • Sales agents can use website and make offers for all their customers (they have a select box with all their customers coming from the ERP)

Standard Business Central/ NAV Endpoints

// get single item (SKU), multiple items WP_REST_Request( 'GET', '/nav/v1/items/' . $nav_item_id); https://nav.torggler.com:8248/WEB_TEST/api/beta/tGItems

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_item_get

// get sales quote lines (items in an offer) WP_REST_Request( 'GET', "/nav/v1/salesQuotes/$sales_quote_id/salesQuoteLines" );

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_salesquoteline_get

// set sales quote lines (i.e. adding an item to cart) new \WP_REST_Request( 'POST', "/nav/v1/salesQuotes/$sales_quote_id/salesQuoteLines" );

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_create_salesquoteline

// get the categories (last level is used for “grouping” of products) WP_REST_Request( 'GET', "/nav/v1/itemCategories/{$id}" ); https://nav.torggler.com:8248/WEB_TEST/api/beta/tGItemCats

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/resources/dynamics_itemcategories

// get a customer (only some info is stored within wc; most important is business central client number) WP_REST_Request( 'GET', "/nav/v1/customer/{$id}" );

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_customer_get

--

// get vendors (to get brands associated with them/ logos https://nav.torggler.com:8248/WEB_TEST/api/beta/vendors

https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_vendor_get

Custom Api Endpoints

// get info on customer (for agents to “switch” into customer role) woocommerceNavConnector.restUrl + 'nav/v1/customerSelectData'

// get item translations (sync starts with main language (de) and then pulls all the translations) WP_REST_Request( 'GET', '/nav/v1/itemTranslations' );

// get the media associated with an item (at the moment only picture); picture comes as encoded blob WP_REST_Request( 'GET', '/nav/v1/itemTranslations' );

// get sync status (how many products still need to be synced etc.) WP_REST_Request( 'GET', '/nav/v1/status' );

// send an order (transform offer into order) WP_REST_Request( 'POST', '/nav/v1/salesHeaders/' . $sales_quote->number );

// get long texts for a specific item (long item name, possibly description) WP_REST_Request( 'POST', "/nav/v1/documentExtendedTexts" );

--

// get all available addresses (for one customer) https://nav.torggler.com:8248/WEB_TEST/api/beta/shipToAddresses

--

// get net prices of products (takes product ids + customer, uses temporary offer in background) https://nav.torggler.com:8248/WEB_TEST/api/beta/netPrices

Other features WooCommerce

  • It can generate the catalog as a pdf, also for single chapters/ products
  • From backend it can also export categories as .xls
  • Current promotions are own section and get data from ERP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment