Plugin Directory

Changeset 3426266


Ignore:
Timestamp:
12/23/2025 02:29:53 PM (3 months ago)
Author:
cocolis
Message:

1.1.5

Location:
cocolis
Files:
126 added
6 edited

Legend:

Unmodified
Added
Removed
  • cocolis/trunk/class/wc-cocolis-payment.php

    r3368324 r3426266  
    214214                        "title" => $product->get_name(),
    215215                        "qty" => $product['qty'],
    216                         "img" => wp_get_attachment_url($data->get_image_id()),
     216                        "photo_urls" => array(wp_get_attachment_url($data->get_image_id())),
    217217                        "height" => (int) $height,
    218218                        "width" => (int) $width,
     
    221221                }
    222222
    223                 $images = [];
    224                 foreach ($arrayproducts as $image) {
    225                     if (!empty($image['img'])) {
    226                         array_push($images, $image['img']);
    227                     }
    228                 }
    229 
    230223                $content_value = (float) ($order->get_total() - $order->get_total_tax() - $order->get_shipping_tax()) * 100; // In cents
    231224                $params = [
    232225                    "description" => "Livraison de la commande : " . implode(", ", $arrayname) . " vendue sur le site marketplace.",
    233226                    "external_id" => $order_id,
     227                    "idempotency_key" =>'cocolis_woocommerce_' . $order_id,
    234228                    "from_address" => $from_composed_address,
    235229                    "from_postal_code" => $store_postcode,
     
    248242                    "volume" => $dimensions,
    249243                    "environment" => "objects",
    250                     "photo_urls" => $images,
    251244                    "content_value" => $content_value, // In cents
    252245                    "rider_extra_information" => "Livraison de la commande : " . implode(", ", $arrayname),
  • cocolis/trunk/class/wc-cocolis-webhooks.php

    r3150616 r3426266  
    8686            $client = $client->getRideClient();
    8787            $ride = $client->get($ride_id);
    88             $slug = $ride->slug;
     88            $id = $ride->id;
    8989            $prod = $shipping_class->settings['production_mode'] == "sandbox" ? false : true;
    9090
     
    9494            $order->add_order_note($note, false);
    9595
    96             $link = $prod ? 'https://cocolis.fr/ride-public/' .
    97                 $slug : 'https://sandbox.cocolis.fr/ride-public/' . $slug;
     96            $base_url = $prod ? 'https://www.cocolis.fr' : 'https://sandbox.cocolis.fr';
     97            $link = sprintf('%s/ride/public/%s', $base_url, $id);
    9898
    9999            $note = __("Link to ad: ", 'cocolis') . $link;
     
    106106    }
    107107
    108     function cocolis_webhook_availabilities_buyer_filled($request)
    109     {
    110         $data = $request->get_json_params();
    111         $orderid = $data['external_id'];
    112         $event = $data['event'];
    113 
    114         if (empty($event) || empty($orderid)) {
    115             echo ('Event or order ID missing from Webhook');
    116             exit;
    117         }
    118 
    119         $order = new WC_Order($orderid);
    120 
    121 
    122         if (!empty($order)) {
    123             $note = __("The buyer has updated his availability", 'cocolis');
    124 
    125             // Add the note
    126             $order->add_order_note($note, false);
    127         }
    128         echo json_encode(['success' => true]);
    129         exit;
    130     }
    131 
    132     function cocolis_webhook_availabilities_seller_filled($request)
    133     {
    134         $data = $request->get_json_params();
    135         $orderid = $data['external_id'];
    136         $event = $data['event'];
    137 
    138         if (empty($event) || empty($orderid)) {
    139             echo ('Event or order ID missing from Webhook');
    140             exit;
    141         }
    142 
    143         $order = new WC_Order($orderid);
    144 
    145 
    146         if (!empty($order)) {
    147             $note = __("The seller has updated his availability", 'cocolis');
     108    function cocolis_webhook_pickup_slot_accepted_by_sender($request)
     109    {
     110        $data = $request->get_json_params();
     111        $orderid = $data['external_id'];
     112        $event = $data['event'];
     113
     114        if (empty($event) || empty($orderid)) {
     115            echo ('Event or order ID missing from Webhook');
     116            exit;
     117        }
     118
     119        $order = new WC_Order($orderid);
     120
     121
     122        if (!empty($order)) {
     123            $note = __("The seller accepted the carrier's pickup slot", 'cocolis');
     124
     125            // Add the note
     126            $order->add_order_note($note, false);
     127        }
     128        echo json_encode(['success' => true]);
     129        exit;
     130    }
     131
     132    function cocolis_webhook_deposit_slot_accepted_by_recipient($request)
     133    {
     134        $data = $request->get_json_params();
     135        $orderid = $data['external_id'];
     136        $event = $data['event'];
     137
     138        if (empty($event) || empty($orderid)) {
     139            echo ('Event or order ID missing from Webhook');
     140            exit;
     141        }
     142
     143        $order = new WC_Order($orderid);
     144
     145
     146        if (!empty($order)) {
     147            $note = __("The buyer has accepted the carrier's delivery slot", 'cocolis');
     148
     149            // Add the note
     150            $order->add_order_note($note, false);
     151        }
     152        echo json_encode(['success' => true]);
     153        exit;
     154    }
     155
     156    function cocolis_webhook_ride_availabilities_pending($request)
     157    {
     158        $data = $request->get_json_params();
     159        $orderid = $data['external_id'];
     160        $event = $data['event'];
     161
     162        if (empty($event) || empty($orderid)) {
     163            echo ('Event or order ID missing from Webhook');
     164            exit;
     165        }
     166
     167        $order = new WC_Order($orderid);
     168
     169
     170        if (!empty($order)) {
     171            $note = __("A carrier offers their services in response to a ride, and confirmation is awaited from the sender and recipient.", 'cocolis');
    148172
    149173            // Add the note
     
    235259            'permission_callback' => '__return_true'
    236260        ));
    237         register_rest_route('cocolis/v1', '/webhook_availabilities_buyer_filled', array(
    238             'methods'  => 'POST',
    239             'callback' => array($this, 'cocolis_webhook_availabilities_buyer_filled'),
    240             'permission_callback' => '__return_true'
    241         ));
    242         register_rest_route('cocolis/v1', '/webhook_availabilities_seller_filled', array(
    243             'methods'  => 'POST',
    244             'callback' => array($this, 'cocolis_webhook_availabilities_seller_filled'),
     261        register_rest_route('cocolis/v1', '/webhook_pickup_slot_accepted_by_sender', array(
     262            'methods'  => 'POST',
     263            'callback' => array($this, 'cocolis_webhook_pickup_slot_accepted_by_sender'),
     264            'permission_callback' => '__return_true'
     265        ));
     266        register_rest_route('cocolis/v1', '/webhook_deposit_slot_accepted_by_recipient', array(
     267            'methods'  => 'POST',
     268            'callback' => array($this, 'cocolis_webhook_deposit_slot_accepted_by_recipient'),
     269            'permission_callback' => '__return_true'
     270        ));
     271        register_rest_route('cocolis/v1', '/webhook_ride_availabilities_pending', array(
     272            'methods'  => 'POST',
     273            'callback' => array($this, 'cocolis_webhook_ride_availabilities_pending'),
    245274            'permission_callback' => '__return_true'
    246275        ));
  • cocolis/trunk/languages/cocolis-fr_FR.po

    r3318609 r3426266  
    33"Project-Id-Version: Cocolis\n"
    44"POT-Creation-Date: 2025-06-27 09:07+0200\n"
    5 "PO-Revision-Date: 2025-06-27 09:08+0200\n"
     5"PO-Revision-Date: 2025-12-23 15:21+0100\n"
    66"Last-Translator: \n"
    77"Language-Team: Cocolis\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=2; plural=(n > 1);\n"
    13 "X-Generator: Poedit 3.6\n"
     13"X-Generator: Poedit 3.8\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-KeywordsList: __\n"
     
    3333
    3434#: class/wc-cocolis-payment.php:86
    35 msgid ""
    36 "Please fill insurance details for Cocolis delivery (refresh if you have "
    37 "changed delivery mode)"
    38 msgstr ""
    39 "Veuillez remplir les détails de l’assurance pour la livraison Cocolis "
    40 "(actualiser si vous avez changé de mode de livraison)"
     35msgid "Please fill insurance details for Cocolis delivery (refresh if you have changed delivery mode)"
     36msgstr ""
     37"Veuillez remplir les détails de l’assurance pour la livraison Cocolis (actualiser si vous avez changé de mode de "
     38"livraison)"
    4139
    4240#: class/wc-cocolis-payment.php:172
     
    6664#: class/wc-cocolis-payment.php:335
    6765msgid "We did not find any related cocolis ads, so the ad was not cancelled."
    68 msgstr ""
    69 "Nous n’avons pas trouvé d’annonces similaires sur Cocolis, l’annonce n’a "
    70 "donc pas été annulée."
     66msgstr "Nous n’avons pas trouvé d’annonces similaires sur Cocolis, l’annonce n’a donc pas été annulée."
    7167
    7268#: class/wc-cocolis-payment.php:358
     
    8379
    8480#: class/wc-cocolis-payment.php:386
    85 msgid ""
    86 "We have find a related cocolis ad to this order, so the ad was not published."
    87 msgstr ""
    88 "Nous avons trouvé une annonce Cocolis apparentée à cette commande, l’annonce "
    89 "n’a donc pas été publiée."
     81msgid "We have find a related cocolis ad to this order, so the ad was not published."
     82msgstr "Nous avons trouvé une annonce Cocolis apparentée à cette commande, l’annonce n’a donc pas été publiée."
    9083
    9184#: class/wc-cocolis-webhooks.php:31
     
    110103
    111104#: class/wc-cocolis-webhooks.php:171
    112 msgid ""
    113 "The delivery is cancelled by the carrier. The seller and the buyer are "
    114 "informed, their tracking page is updated."
    115 msgstr ""
    116 "La livraison est annulée par le transporteur. Le vendeur et l’acheteur sont "
    117 "informés, leur page de suivi est mise à jour."
     105msgid "The delivery is cancelled by the carrier. The seller and the buyer are informed, their tracking page is updated."
     106msgstr ""
     107"La livraison est annulée par le transporteur. Le vendeur et l’acheteur sont informés, leur page de suivi est mise à "
     108"jour."
    118109
    119110#: class/wc-cocolis-webhooks.php:195
    120 msgid ""
    121 "The ride did not find a carrier. Get closer to our support and with "
    122 "cocolis.fr"
    123 msgstr ""
    124 "Le trajet n’a pas trouvé de transporteur. Rapprochez-vous de notre support "
    125 "et avec cocolis.fr"
     111msgid "The ride did not find a carrier. Get closer to our support and with cocolis.fr"
     112msgstr "Le trajet n’a pas trouvé de transporteur. Rapprochez-vous de notre support et avec cocolis.fr"
    126113
    127114#: wc-cocolis-shipping.php:49
     
    138125
    139126#: wc-cocolis-shipping.php:118
    140 msgid ""
    141 "The configuration of the Cocolis module is not correctly configured to fully "
    142 "use it."
    143 msgstr ""
    144 "La configuration du module Cocolis n’est pas correctement configurée pour "
    145 "l’utiliser pleinement."
     127msgid "The configuration of the Cocolis module is not correctly configured to fully use it."
     128msgstr "La configuration du module Cocolis n’est pas correctement configurée pour l’utiliser pleinement."
    146129
    147130#: wc-cocolis-shipping.php:124
    148 msgid ""
    149 "The address entered in the Woocommerce settings is not properly configured "
    150 "to fully use the Cocolis module."
    151 msgstr ""
    152 "L’adresse saisie dans les paramètres de Woocommerce n’est pas correctement "
    153 "configurée pour utiliser pleinement le module Cocolis."
     131msgid "The address entered in the Woocommerce settings is not properly configured to fully use the Cocolis module."
     132msgstr ""
     133"L’adresse saisie dans les paramètres de Woocommerce n’est pas correctement configurée pour utiliser pleinement le "
     134"module Cocolis."
    154135
    155136#: wc-cocolis-shipping.php:135
     
    198179
    199180#: wc-cocolis-shipping.php:171
    200 msgid ""
    201 "Allows you to calculate the costs in the absence of the width indicated in "
    202 "the product sheet."
    203 msgstr ""
    204 "Permet de calculer les coûts en l’absence de la largeur indiquée dans la "
    205 "fiche produit."
     181msgid "Allows you to calculate the costs in the absence of the width indicated in the product sheet."
     182msgstr "Permet de calculer les coûts en l’absence de la largeur indiquée dans la fiche produit."
    206183
    207184#: wc-cocolis-shipping.php:177
     
    210187
    211188#: wc-cocolis-shipping.php:179
    212 msgid ""
    213 "Allows you to calculate the costs in the absence of the height indicated in "
    214 "the product sheet."
    215 msgstr ""
    216 "Permet de calculer les coûts en l’absence de la hauteur indiquée dans la "
    217 "fiche produit."
     189msgid "Allows you to calculate the costs in the absence of the height indicated in the product sheet."
     190msgstr "Permet de calculer les coûts en l’absence de la hauteur indiquée dans la fiche produit."
    218191
    219192#: wc-cocolis-shipping.php:185
     
    222195
    223196#: wc-cocolis-shipping.php:187
    224 msgid ""
    225 "Allows you to calculate the costs in the absence of the length indicated in "
    226 "the product sheet."
    227 msgstr ""
    228 "Permet de calculer les coûts en l’absence de la longueur indiquée dans la "
    229 "fiche produit."
     197msgid "Allows you to calculate the costs in the absence of the length indicated in the product sheet."
     198msgstr "Permet de calculer les coûts en l’absence de la longueur indiquée dans la fiche produit."
    230199
    231200#: wc-cocolis-shipping.php:193
     
    235204#: wc-cocolis-shipping.php:195
    236205msgid "Required for the ride creation at Cocolis (vendor email)"
    237 msgstr ""
    238 "Nécessaire pour la création d’une annonce chez Cocolis (email du vendeur)"
     206msgstr "Nécessaire pour la création d’une annonce chez Cocolis (email du vendeur)"
    239207
    240208#: wc-cocolis-shipping.php:201
     
    244212#: wc-cocolis-shipping.php:203
    245213msgid "Required for the ride creation at Cocolis (landline or cell phone)"
    246 msgstr ""
    247 "Requis pour la création de trajet chez Cocolis (téléphone fixe ou cellulaire)"
     214msgstr "Requis pour la création de trajet chez Cocolis (téléphone fixe ou cellulaire)"
    248215
    249216#: wc-cocolis-shipping.php:225
    250217msgid "The credentials provided are not recognized by the Cocolis API."
    251 msgstr ""
    252 "Les informations d’identification fournies ne sont pas reconnues par l’API "
    253 "Cocolis."
     218msgstr "Les informations d’identification fournies ne sont pas reconnues par l’API Cocolis."
    254219
    255220#: wc-cocolis-shipping.php:225
     
    263228#: wc-cocolis-shipping.php:445
    264229msgid ""
    265 "Cocolis insurance included. <a target='_blank' href='https://www.cocolis.fr/"
    266 "static/docs/notice_information_COCOLIS_ACM.pdf'>Notice</a>"
    267 msgstr ""
    268 "Assurance Cocolis incluse. <a target='_blank' href='https://www.cocolis.fr/"
    269 "static/docs/notice_information_COCOLIS_ACM.pdf'>Notice d'assurance</a>"
     230"Cocolis insurance included. <a target='_blank' href='https://www.cocolis.fr/static/docs/"
     231"notice_information_COCOLIS_ACM.pdf'>Notice</a>"
     232msgstr ""
     233"Assurance Cocolis incluse. <a target='_blank' href='https://www.cocolis.fr/static/docs/"
     234"notice_information_COCOLIS_ACM.pdf'>Notice d'assurance</a>"
    270235
    271236#: wc-cocolis-shipping.php:461
     
    273238msgstr "Assurance complémentaire jusqu'à "
    274239
    275 #~ msgid ""
    276 #~ "Cocolis has cancelled the ride associated with this order following your "
    277 #~ "customer refund."
    278 #~ msgstr ""
    279 #~ "Cocolis a annulé le trajet associé à cette commande suite à votre "
    280 #~ "remboursement client."
    281 
    282 #~ msgid "The public ride URL : "
    283 #~ msgstr "L’URL de l’annonce publique : %s "
    284 
    285 #~ msgid "Buyer tracking delivery URL : "
    286 #~ msgstr "URL de livraison de suivi de l’acheteur : %s "
    287 
    288 #~ msgid "[Private] Seller tracking delivery URL : "
    289 #~ msgstr "[Privé] URL de livraison de suivi du vendeur : "
    290 
    291 #~ msgid "Birth date required for insurance"
    292 #~ msgstr "Date de naissance requise pour l’assurance"
     240msgid "Birth date required for insurance"
     241msgstr "Date de naissance requise pour l’assurance"
     242
     243msgid "A carrier offers their services in response to a ride, and confirmation is awaited from the sender and recipient."
     244msgstr ""
     245"Un transporteur propose ses services en réponse à une demande de transport, et attend la confirmation de l'expéditeur "
     246"et du destinataire."
     247
     248msgid "The buyer has accepted the carrier's delivery slot"
     249msgstr "L'acheteur a accepté le créneau de livraison du transporteur"
     250
     251msgid "The seller accepted the carrier's pickup slot"
     252msgstr "Le vendeur a accepté le créneau horaire proposé par le transporteur pour l'enlèvement"
  • cocolis/trunk/readme.txt

    r3368324 r3426266  
    44Stable tag: 1.1.3
    55Requires at least: 4.7
    6 Tested up to: 6.8
     6Tested up to: 6.8.2
    77Requires PHP: 5.6.0
    88License: GPLv2 or later
     
    4949
    5050== Changelog ==
     51= 1.1.5 =
     52* Fix an issue on installation when creating webhooks
     53* Attach photos to ride objects instead of ride itself
     54
    5155= 1.1.4 =
    5256* Fix a php warning
  • cocolis/trunk/wc-cocolis-shipping.php

    r3368324 r3426266  
    77 * Author:  Cocolis.fr
    88 * Author URI: https://www.cocolis.fr
    9  * Version: 1.1.4
     9 * Version: 1.1.5
    1010 * Developer: Alexandre BETTAN, Sebastien FIELOUX
    1111 * Developer URI: https://github.com/btnalexandre, https://github.com/sebfie
     
    253253                    $webhooks = $client->getWebhookClient()->getAll();
    254254
     255                    $required_events = [
     256                        'ride_published',
     257                        'ride_expired',
     258                        'offer_accepted',
     259                        'offer_cancelled',
     260                        'offer_completed',
     261                        'pickup_slot_accepted_by_sender',
     262                        'deposit_slot_accepted_by_recipient',
     263                        'ride_availabilities_pending'
     264                    ];
     265
     266                    $existing_webhooks = [];
    255267                    if (!empty($webhooks)) {
    256268                        foreach ($webhooks as $webhook) {
    257                             if (strpos($webhook->url, get_home_url()) !== true) {
     269                            $existing_webhooks[$webhook->event] = $webhook;
     270                        }
     271                    }
     272
     273                    foreach ($required_events as $event) {
     274                        $webhook_url = get_home_url() . '/wp-json/cocolis/v1/webhook_' . $event;
     275
     276                        if (isset($existing_webhooks[$event])) {
     277                            $existing_webhook = $existing_webhooks[$event];
     278                            if ($existing_webhook->url !== $webhook_url) {
    258279                                $client->getWebhookClient()->update(
    259280                                    [
    260                                         'event' => $webhook->event,
    261                                         'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_' . $webhook->event,
     281                                        'event' => $event,
     282                                        'url' => $webhook_url,
    262283                                        'active' => true
    263284                                    ],
    264                                     $webhook->id
     285                                    $existing_webhook->id
    265286                                );
    266287                            }
     288                        } else {
     289                            $client->getWebhookClient()->create([
     290                                'event' => $event,
     291                                'url' => $webhook_url,
     292                                'active' => true
     293                            ]);
    267294                        }
    268                     } else {
    269                         $client->getWebhookClient()->create([
    270                             'event' => 'ride_published',
    271                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_ride_published',
    272                             'active' => true
    273                         ]);
    274                         $client->getWebhookClient()->create([
    275                             'event' => 'ride_expired',
    276                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_ride_expired',
    277                             'active' => true
    278                         ]);
    279                         $client->getWebhookClient()->create([
    280                             'event' => 'offer_accepted',
    281                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_offer_accepted',
    282                             'active' => true
    283                         ]);
    284                         $client->getWebhookClient()->create([
    285                             'event' => 'offer_cancelled',
    286                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_offer_cancelled',
    287                             'active' => true
    288                         ]);
    289                         $client->getWebhookClient()->create([
    290                             'event' => 'offer_completed',
    291                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_offer_completed',
    292                             'active' => true
    293                         ]);
    294                         $client->getWebhookClient()->create([
    295                             'event' => 'availabilities_buyer_filled',
    296                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_availabilities_buyer_filled',
    297                             'active' => true
    298                         ]);
    299                         $client->getWebhookClient()->create([
    300                             'event' => 'availabilities_seller_filled',
    301                             'url' => get_home_url() . '/wp-json/cocolis/v1/webhook_availabilities_seller_filled',
    302                             'active' => true
    303                         ]);
    304295                    }
    305296                }
Note: See TracChangeset for help on using the changeset viewer.