WooCommerce icon indicating copy to clipboard operation
WooCommerce copied to clipboard

Submitting a valid tracking instead of a plain shipAll()

Open NulSEO opened this issue 5 years ago • 2 comments

Hi guys,

I'm a little confused. Klarnas ToS clearly say that you're obligated to submit a valid tracking - the official plugin however doesn't seem to care about that really (for whatever reason ;-))

There are multiple fulfillment plugins, but the majority of the people is using https://woocommerce.com/products/shipment-tracking/ - Supporting this plugin is pretty necessary I believe, especially for people that sell a lot through Klarna.

Adding support for this plugin is incredibly simple, I'm not sure why this hasn't been done yet.

Mollie/WC/Plugin.php (shipAndCaptureOrderAtMollie()):

// [...]
if ($mollie_order->isPaid() || $mollie_order->isAuthorized()) {
    $trackingInfo = get_post_meta($order->id, '_wc_shipment_tracking_items', true);

    if (empty($trackingInfo)) {
        Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode)->orders->get($mollie_order_id)->shipAll();
        $order->add_order_note('Order successfully updated to shipped at Mollie, capture of funds underway.');
        Mollie_WC_Plugin::debug(__METHOD__ . ' - ' . $order_id . ' - Order successfully updated to shipped at Mollie, capture of funds underway.');
        return;
    }

    $trackingInfo = (object)$trackingInfo[0];
    $carrierName = !empty($trackingInfo->tracking_provider) ? $trackingInfo->tracking_provider : $trackingInfo->custom_tracking_provider;
    if (empty($carrierName)) {
        Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode)->orders->get($mollie_order_id)->shipAll();
        $order->add_order_note("Fulfillment doesn't seem to have a tracking tracking number. Fulfilling order without tracking info.");
        return;
    }

    if (empty($trackingInfo->tracking_number)) {
        Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode)->orders->get($mollie_order_id)->shipAll();
        $order->add_order_note("Fulfillment doesn't seem to have a tracking tracking number. Fulfilling order without tracking info.");
        return;
    }

    $trackingLink = !empty($trackingInfo->tracking_link) ? $trackingInfo->tracking_link : $trackingInfo->custom_tracking_link;
    if (empty($trackingLink)) {
        Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode)->orders->get($mollie_order_id)->shipAll();
        $order->add_order_note("Fulfillment doesn't seem to have a tracking link. Fulfilling order without tracking info.");
        return;
    }

    $tracking = [];
    $tracking['tracking'] = [
        'carrier' => $carrierName,
        'code' => $trackingInfo->tracking_number,
        'url' => $trackingLink
    ];
    Mollie_WC_Plugin::getApiHelper()->getApiClient($test_mode)->orders->get($mollie_order_id)->shipAll($tracking);
    // [...]
}

NulSEO avatar Oct 03 '20 16:10 NulSEO

Any new information here ? How could I import the trackingnumbers from any order to mollie ?

oleohlen avatar Jul 11 '22 19:07 oleohlen

Hi!

I can understand if Mollie doesn't want to support different shipment plugins, but a simple hook to provide a value for shipAll() should be easy enough? That way support can be added externally without hacking the plugin code every time.

Kimmax avatar Nov 21 '23 13:11 Kimmax