shopify-php-sdk icon indicating copy to clipboard operation
shopify-php-sdk copied to clipboard

how to get response data where $obj->create()?

Open lyongdee opened this issue 7 years ago • 0 comments

how to get response data when $obj->create()?

ScriptTagService.php

public function update(ScriptTag $scriptTag)
{
    $data = $scriptTag->exportData();
    $response = $this->request(
        '/admin/script_tags/'.$scriptTag->id.'.json', 'PUT', array(
        'script_tag' => $data
        )
    );
    $scriptTag->setData($response['script_tag']);
}

Fix:

public function create(ScriptTag &$scriptTag)
{
    $data = $scriptTag->exportData();
    $response = $this->request(
        '/admin/script_tags.json', 'POST', array(
        'script_tag' => $data
        )
    );
    //$scriptTag->setData($response['script_tag']);
    return $response['script_tag'];
}

lyongdee avatar Jun 11 '18 10:06 lyongdee