Don't have account? Sign up here.

Products & inventory

Sample PHP code to call Products & stock methods

You have to create an XML to call a proper method. After creating the request XML you can use such kind of code.

$opts = array(
    'http' => array(
        'method'  => 'POST',
        'header'  => array(
            'Connection: close',
            'Content-Type: text/xml; charset=utf-8',
            'Content-Length: '.strlen($xml)
        ),
        'content' => $xml
    )
);
$context = stream_context_create($opts);
$response = file_get_contents("https://co3app.com/api/product", false, $context);
echo $response;

Every method will return with an XML response.

Methods for the Produts & stock plugin

getProduct

Gives back all products from the account based on the given filter criteria. You have to set a search criteria for the products’ manufacturer, name, product group, tags, SKU, foreign SKU, EAN fields with the filter field. The maximum number of products in the response would be 1000.

Sample request XML:

<?xml version="1.0" encoding="utf-8"?>
<command>
    <getProduct>
        <api_key><![CDATA[put-your-api-key-here]]></api_key>
        <session_key><![CDATA[put-your-session-key-here]]></session_key>
        <filter><![CDATA[keyword]]></filter>
    </getProduct>
</command>

setProduct

Create a new product or modify an existing one. The method will give back the product ID after succesfully created. This can be used for later reference for eg. in a webshop. The product’s photo will be downloaded automatically from the given URL and saved in the account. If the takein_ tags filled in automatic take in will be placed.

Special XML tags’ description:

  • action – 0 or 1. 1 means the product is under sale or any other special action.
  • id – 0 if you like to create a new product. If a valid product ID set the product will be modified
  • discount1, 2, 3 – The number means a percentage.
  • service - If set to 0 it will be a product. If set to 1 it will be a service. Products has stock quantity and value meanwhile services has not.
  • country code - ISO 3166-1 alpha-2 code of the manufacturing country
  • envfee_code - Environtmental fee code which values can be defined on Products / Settings / Environmental fees page.
  • takein_quantity – Number to take in.
  • takein_contact_id – The contact from who the product came.
  • takein_product_type – 1 means normal product, 3 means a voucher.
  • takein_start_serial_number – If the product type is 3 you can define the first voucher number. Other cases it is optional.

Tags beginning of takein_ needed only if you like to take in some quantity of the product immediatelly. Otherwise do not specify them or leave them blank.

Sample request XML:

        <?xml version="1.0" encoding="utf-8"?>
        <command>
            <setProduct>
                <api_key><![CDATA[put-your-api-key-here]]></api_key>
                <session_key><![CDATA[put-your-session-key-here]]></session_key>
                <manufacturer><![CDATA[Apple Inc.]]></manufacturer>
                <product_name><![CDATA[iPhone 5S]]></product_name>
                <item_number><![CDATA[SKU1284287648]]></item_number>
                <ean_number><![CDATA[700285066104]]></ean_number>
                <foreign_item_number><![CDATA[TTI0003]]></foreign_item_number>
                <vtsz_number><![CDATA[13456789]]></vtsz_number>
                <product_group><![CDATA[Mobile phones]]></product_group>
                <description><![CDATA[Put your marketing message and specification here.]]></description>
                <notes><![CDATA[The note should be used for internal use only.]]></notes>
                <tags>
                    <tag><![CDATA[mobile]]></tag>
                    <tag><![CDATA[3G]]></tag>
                    <tag><![CDATA[high end]]></tag>
                </tags>
                <action>1</action>
                <list_price>1000.00</list_price>
                <wholesale_price>800.00</wholesale_price>
                <purchase_price>900.00</purchase_price>
                <currency>EUR</currency>
                <vat>27.00</vat>
                <unit><![CDATA[pcs]]></unit>
                <depreciation>3</depreciation>
                <discount1>10</discount1>
                <discount2>15</discount2>
                <discount3>20</discount3>
                <photo><![CDATA[http://images.apple.com/iphone-5s/specs/images/color_gray.jpg]]></photo>
                <size><![CDATA[125 x 65 x 13mm]]></size>
                <color><![CDATA[Light-blue]]></color>
                <net_weight>10.53</net_weight>
                <accounting_number>452</accounting_number>
                <service>0</service>
                <country_code>DK</country_code>
                <envfee_code></envfee_code>
                <id>0</id>

                <takein_quantity>1</takein_quantity>
                <takein_price>125.50</takein_price>
                <takein_currency>EUR</takein_currency>
                <takein_fxrate>301.23</takein_fxrate> <!-- If the account's default currency is different -->
                <takein_contact_id>134</takein_contact_id>
                <takein_date>2015-12-01</takein_date>
                <takein_warehouse><![CDATA[Name-of-the-warehouse]]></takein_warehouse>
                <takein_product_type>1</takein_product_type>
                <takein_start_serial_number>2235435</takein_start_serial_number>
                <takein_gross_weight>12.4532</takein_gross_weight>
                <takein_package_type>1</takein_package_type>
                <takein_country_code>HU</takein_country_code> <!-- Origin country in ISO 3166-1 alpha-2 -->
                <takein_batch_no>123AB</takein_batch_no>
                <takein_expire_date>2022-12-12</takein_expire_date>

            </setProduct>
        </command>

getQuantity

Get the current quantity of product from the specified warehouse. If you like the get the quantity from all of the warehouse you can use the * (asterisk) character as the name of the warehouse. The response will contain the deliverable, pending and available quantity.

Sample request XML:

<?xml version="1.0" encoding="utf-8"?>
<command>
    <getQuantity>
        <api_key><![CDATA[put-your-api-key-here]]></api_key>
        <session_key><![CDATA[put-your-session-key-here]]></session_key>
        <product_id>6</product_id>
        <warehouse><![CDATA[default]]></warehouse>
    </getQuantity>
</command>

setQuantity

Set quantity for the specified product. If the quantity less then zero (negative) a wasting receipt will be created. If the quantity more than zero (positive) a take in receipt will be created.

Special XML tags’ description:

  • product_id - ID of the product
  • quantity - quantity to change the current stock volume
  • contact_id – The action has to be contacted to a partner from the partner database. You can read out the contact_id with the help of the CRM API method getContacts.
  • warehouse - The exact name of the warehouse where the operation will take place.
  • price – This is the purchase price of the product when the action is take in.
  • product_type – 1 means normal product, 3 means a voucher.
  • start_serial_number – If the product type is 3 you can define the first voucher number. Other cases it is optional.
  • currency - The currency of the operation.
  • fxrate - Foreign exchange rate if the currency is different than the product's default currency.
  • date - Date of the operation.
  • gross_weight - The gross weight of the package
  • package_type - Type code of the package. This can be different account by account.
  • country_code - Country of origin.
  • batch_no - Batch number if needed.
  • expire_date - Expiry date if needed.

Sample request XML:

        <?xml version="1.0" encoding="utf-8"?>
        <command>
            <setQuantity>
                <api_key><![CDATA[put-your-api-key-here]]></api_key>
                <session_key><![CDATA[put-your-session-key-here]]></session_key>
                <product_id>6</product_id>
                <quantity>5</quantity>
                <contact_id>1</contact_id>
                <warehouse><![CDATA[first]]></warehouse>
                <price>800.00</price>
                <product_type>1</product_type>
                <start_serial_number><![CDATA[]]></start_serial_number>
                <currency><![CDATA[EUR]]></currency>
                <fxrate>301.23</fxrate> <!-- if the currency is different from the currency of the product -->
                <date>2015-12-01</date>
                <gross_weight>12.4532</gross_weight>
                <package_type>1</package_type>
                <country_code>HU</country_code> <!-- Origin country in ISO 3166-1 alpha-2 -->
                <batch_no>123AB</batch_no>
                <expire_date>2022-12-12</expire_date>       
            </setQuantity>
        </command>

getOrderStatus

Get order status by ID. You can get the order ID after sending them through the API. The response will contain the order ID. If you build a webshop you should store the orders’ ID after getting them.

Sample request XML:

        <?xml version="1.0" encoding="utf-8"?>
        <command>
            <getOrderStatus>
                <api_key><![CDATA[put-your-api-key-here]]></api_key>
                <session_key><![CDATA[put-your-session-key-here]]></session_key>
                <order_id>76</order_id>
            </getOrderStatus>
        </command>

setOrder

Create a new order in CO3. You have to specify the header of the order first and then you can specify as many item rows as you like. If the sending was successful the response will include the order ID. You can refer the order ID in other API methods if you like to follow up the status of the order.

Value sets in the header:

  • warehouse – “Default” or the unique name of the warehouse. If you specify * the system will select the warehouse automatically
  • shipping_aim – Sale, Allocation or Overstore. If you need more options here please contact us.
  • method – transfer, cash, bankcard, cheque, other, c.o.d., direct debit
  • selected_account - One of the account number which is defined in the system. Excat match needed.
  • contact_id – you have to use the CRM API to get the id of the specific contact
  • currency – supported currenices: USD, GBP, EUR, HUF (if you need other please contact us)
  • language – supported locales are hu_HU, en_US, de_DE, pl_PL, es_ES
  • product_id – the ID of the product. This is a mandatory field.
  • quantity - Quantity of the product. Mandatory field.
  • custom_price – if specified the product’s list price will be overwritten on the order. If empty the product's list price will be used.
  • custom_fields - Can be used if any custom field was specified on the Products & stock / Settings / Custom fields page. The name of the tags have to be matched with the name of the specified custom fields.

You can handle the orders in the CO3 GUI after creating. The orders will be created as delivery notes in Saved status. You can find them in Products & stock / Customer orders page or Products & stock / Delivery notes page.

Sample request XML:

        <?xml version="1.0" encoding="utf-8"?>
        <command>
            <setOrder>
                <api_key><![CDATA[put-your-api-key-here]]></api_key>
                <session_key><![CDATA[put-your-session-key-here]]></session_key>
                <warehouse><![CDATA[Name of your warehouse]]></warehouse>
                <shipping_aim><![CDATA[sale]]></shipping_aim>
                <method><![CDATA[cash]]></method>
                <issued_date>2013-07-02</issued_date>
                <selected_account>12345678-12345678-12345678</selected_account>
                <contact_id>1</contact_id>
                <order_description><![CDATA[Order description]]></order_description>
                <currency>EUR</currency>
                <language>de_DE</language>
                <issuer_swift>COBADEFF</issuer_swift>
                <issuer_email>accounting@acme.com</issuer_email>
                <issuer_phone>123456789</issuer_phone>
                <items>
                    <item>
                        <product_id>1234</product_id>
                        <quantity>1.00</quantity>
                        <custom_price>200.00</custom_price>
                        <discount>0</discount>
                        <description><![CDATA[Item description]]></description>
                    </item>
                </items>
                <custom_fields>
                    <example_checkbox>
                        <node>yes</node>
                    </example_checkbox>
                    <example_text><![CDATA[Some text]]></example_text>
                </custom_fields>                
            </setOrder>
        </command>

getWarehouses

Get all of the warehouses which is active in the system.

Sample request XML:

        <?xml version="1.0" encoding="utf-8"?>
        <command>
            <getWarehouses>
                <api_key><![CDATA[put-your-api-key-here]]></api_key>
                <session_key><![CDATA[put-your-session-key-here]]></session_key>
            </getWarehouses>
        </command>

setWarehouse

Create a new warehouse.

Sample request XML:

        <?xml version="1.0" encoding="utf-8"?>
        <command>
            <setWarehouse>
                <api_key><![CDATA[put-your-api-key-here]]></api_key>
                <session_key><![CDATA[put-your-session-key-here]]></session_key>
                <name><![CDATA[Warehouse name]]></name>
                <postal_code>NY14235</postal_code>
                <city>New York</city>
                <street><![CDATA[Delaware street 712.]]></street>                
            </setWarehouse>
        </command>