• Resolved pujithamutyala

    (@pujithamutyala)


    Hi Team,

    We are developing an app for our WooCommerce store where we use the WooCommerce rest api as the backend. So as a Shipping option, we use Dropp and we create a shipping order using the Dropp Rest API. But the Dropp booking details are not shown in WooCommerce Order details. How do we connect the Woocommerce order and the Dropp Shipping order?

    Thanks & Regards,

    Pujitha

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Eivin Landa

    (@forsvunnet)

    Hi Pujitha,

    In order to display the dropp consignments in the WooCommerce admin you would need to create rows in the {$wpdb->prefix}dropp_consignments table. Preferably you would do that by creating a new Dropp_Consignment object and then using the fill method to populate the properties and save to insert into the database.

    // Required values for the fill method
    // file: models/class-dropp-consignment.php:115
    $requires_value = [
    	'barcode',
    	'dropp_order_id',
    	'shipping_item_id',
    	'location_id',
    ];

    Alternatively you can insert directly into the database, but please note that this would increase the risk of future breakage as we may choose to alter the database table in the future.

    Thread Starter pujithamutyala

    (@pujithamutyala)

    Is there any way to do it using WooCommerce Rest API?

    Plugin Author Eivin Landa

    (@forsvunnet)

    There is currently no way to do it via the API.
    I’ve asked GPT to write some code to add an endpoint to the API and it gave me some code that looks promising. I’ll test it and get back to you if it’s something we’ll implement.

    Plugin Author Eivin Landa

    (@forsvunnet)

    Hi again,

    I did some more digging and found that we at one point added support for adding dropp order ids on the shipping item meta field dropp_consignments as either an array or a comma separated string.

    Note that it’s important that you use the correct shipping method id. Regular dropp shipments have the id dropp_is and shipments outside of capital area have the id dropp_is_oca. You can find the id’s in the __construct method of the shipping method class files located in the classes/shipping-method directory.

    I did encounter a bug when I tested that I fixed. That means that you might need to try this with the unreleased version of the plugin that you can find here: https://github.com/CoveAS/dropp-for-woocommerce/archive/refs/heads/master.zip

    Here’s my example code:

    <?php
    
    require __DIR__ . '/vendor/autoload.php';
    
    use Automattic\WooCommerce\Client;
    
    $woocommerce = new Client(
      'https://dropp.test',
      'ck_******',
      'cs_******',
      [
        'version' => 'wc/v3',
      ]
    );
    
    // Order data
    $data = [
        'payment_method' => 'bacs',
        'payment_method_title' => 'Direct Bank Transfer',
        'set_paid' => true,
        'shipping_lines' => [
            [
                'method_id' => 'dropp_is',
                'method_title' => 'Dropp',
                'total' => '10.00',
                'meta_data' => [
                    [
                        'key' => 'dropp_consignments',
                        'value' => '5f889916-2f0a-4baf-91af-cc16ebe74369',
                    ],
                ],
            ],
        ],
        // Add other order details as needed
    ];
    
    $woocommerce->post('orders', $data);

    Please consider giving the plugin a five star review if you found this helpful ??

    Thread Starter pujithamutyala

    (@pujithamutyala)

    This is very helpful. Thank you so much. Is there any timeline when this version of the plugin will be released ?

    Plugin Author Eivin Landa

    (@forsvunnet)

    New version has been published now ??

    Thread Starter pujithamutyala

    (@pujithamutyala)

    Hi Eivin, I get the below error when I try to open an order with Dropp shipping Options in Word Press Woocommerce Admin page. Does this mean Social Security Number is mandatory while creating an order with Dropp?

    Error Details
    =============
    An error of type E_ERROR was caused in line 62 of the file /srv/htdocs/wp-content/plugins/dropp-for-woocommerce/classes/models/class-dropp-customer.php. Error message: Uncaught TypeError: Cannot assign null to property Dropp\Models\Dropp_Customer::$social_security_number of type string in /srv/htdocs/wp-content/plugins/dropp-for-woocommerce/classes/models/class-dropp-customer.php:62
    Stack trace:
    #0 /srv/htdocs/wp-content/plugins/dropp-for-woocommerce/classes/models/class-dropp-consignment.php(148): Dropp\Models\Dropp_Customer->fill(Array)
    #1 /srv/htdocs/wp-content/plugins/dropp-for-woocommerce/classes/models/class-dropp-consignment.php(588): Dropp\Models\Dropp_Consignment->fill(Array)
    #2 /srv/htdocs/wp-content/plugins/dropp-for-woocommerce/classes/actions/class-convert-dropp-order-ids-to-consignments-action.php(49): Dropp\Models\Dropp_Consignment::remote_find(652, ‘1d99a458-ec2c-4…’)
    #3 /srv/htdocs/wp-content/plugins/dropp-for-woocommerce/classes/class-shipping-meta-box.php(115): Dropp\Actions\Convert_Dropp_Order_Ids_To_Consignments_Action->handle()
    #4 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(324): Dropp\Shipping_Meta_Box::admin_enqueue_scripts(‘post.php’)
    #5 /wordpress/core/6.4.3/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
    #6 /wordpress/core/6.4.3/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #7 /wordpress/core/6.4.3/wp-admin/admin-header.php(118): do_action(‘admin_enqueue_s…’, ‘post.php’)
    #8 /wordpress/core/6.4.3/wp-admin/edit-form-advanced.php(425): require_once(‘/wordpress/core…’)
    #9 /wordpress/core/6.4.3/wp-admin/post.php(206): require(‘/wordpress/core…’)
    #10 {main}
    thrown

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How do we connect Dropp Order created via API to a WooCommerce Order?’ is closed to new replies.