Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSWebServiceLibrary with sendemail=1 parameter does not work #37249

Open
2 tasks done
Codencode opened this issue Oct 24, 2024 · 1 comment · May be fixed by PrestaShop/PrestaShop-webservice-lib#102
Open
2 tasks done
Labels
Bug Type: Bug Carriers Label: Which BO under menu is concerned NMI Status: issue needs more information Waiting for dev Status: action required, waiting for tech feedback WS Category: Web Service

Comments

@Codencode
Copy link
Contributor

Prerequisites

Describe the bug and add attachments

In case of updating the order_carrier entity via webservice, passing the sendmail parameter the system does not work.

The problem is in the PrestaShopWebservice::edit() method https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/3fad904e9e8ab57dd890a75ba1bf23981171291a/PSWebServiceLibrary.php#L451-L465
you should invert the if with the else

I attach a test script

define('PS_SHOP_PATH', '');
define('PS_WS_AUTH_KEY', '');
define('ORDER_ID', '');

require_once('./PSWebServiceLibrary.php');


try {

    $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);

    $xml = $webService->get([
        'resource' => 'order_carriers',
        'filter[id_order]' => ORDER_ID
    ]);

    $orderCarrierId = (int) $xml->order_carriers->order_carrier->attributes()->id;

    $xml = $webService->get([
        'resource' => 'order_carriers',
        'id' => $orderCarrierId,
    ]);

    $xml->order_carrier->tracking_number = "modificato";

    $opt = [
        'url' => PS_SHOP_PATH . 'api/order_carriers/' . $orderCarrierId . '?sendemail=1',
        'putXml' => $xml->asXML(),
        'id' => $orderCarrierId,
    ];

    $webService->edit($opt);
} catch (PrestaShopWebserviceException $ex) {
    echo 'Other error: <br />' . $ex->getMessage();
}

Expected behavior

No response

Steps to reproduce

Use the attached script

PrestaShop version(s) where the bug happened

PSWebServiceLibrary

PHP version(s) where the bug happened

No response

If your bug is related to a module, specify its name and its version

No response

Your company or customer's name goes here (if applicable).

@Codencode

@Codencode Codencode added Bug Type: Bug New New issue not yet processed by QA labels Oct 24, 2024
@florine2623 florine2623 added WS Category: Web Service NMI Status: issue needs more information Carriers Label: Which BO under menu is concerned Waiting for dev Status: action required, waiting for tech feedback and removed New New issue not yet processed by QA labels Oct 25, 2024
@Codencode
Copy link
Contributor Author

The problem is that this library does not allow sending additional parameters.
For example, if I want to set the tracking number and send the "In transit" email, I can't do it.

https://github.com/PrestaShop/PrestaShop/blob/18b68e6905d087794562ad2a6c80ab11c069b4f7/classes/order/OrderCarrier.php#L183C1-L194C10

In the OrderCarrier::updateWs() method, the email is sent if the sendemail parameter is passed, but this parameter cannot be passed to the library in question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Type: Bug Carriers Label: Which BO under menu is concerned NMI Status: issue needs more information Waiting for dev Status: action required, waiting for tech feedback WS Category: Web Service
Projects
None yet
2 participants