Skip to content

Conversation

@Codencode
Copy link

@Codencode Codencode commented Oct 24, 2024

Questions Answers
Description? In case of updating the order_carrier entity via webservice, passing the sendmail parameter the system does not work.
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #37249
Sponsor company @Codencode
How to test? see PrestaShop/PrestaShop#37249

@ps-jarvis
Copy link

Hello @Codencode!

This is your first pull request on PrestaShop-webservice-lib repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

@Codencode
Copy link
Author

Perhaps a better solution could be to include an additional parameter to be passed, allowing the specification of extra parameters to be "appended" to the URL.

For example:

    $opt = [
        'resource' => 'order_carriers',
        'putXml' => $xml->asXML(),
        'id' => $orderCarrierId,
        'additionasUrlFields' => [
            'sendmail' => 1,
        ]
    ];

    $webService->edit($opt);
    
    ##### method "Edit    
    public function edit($options)
    {
        $xml = '';
        if ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) {
            $url = (isset($options['url']) ? $options['url'] :
                $this->url . '/api/' . $options['resource'] . '/' . $options['id']);
            $xml = $options['putXml'];
            if (isset($options['id_shop'])) {
                $url .= '&id_shop=' . $options['id_shop'];
            }
            if (isset($options['id_group_shop'])) {
                $url .= '&id_group_shop=' . $options['id_group_shop'];
            }
            // START new code
            if (isset($options['additionasUrlFields'])) {
                $url .= '?' . http_build_query($options['additionasUrlFields']);
            }
            // END new code
        } else {
            throw new PrestaShopWebserviceException('Bad parameters given');
        }

        $request = $this->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml));
        $this->checkStatusCode($request);// check the response validity
        return $this->parseXML($request['response']);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

PSWebServiceLibrary with sendemail=1 parameter does not work

2 participants