Jump to content

Edit History

easyjava

easyjava

Hello,

I use the webservice to get some informations about a product. I need the final price so I use price[my_price][use_tax]=1 and it works very well with the url :

api/products/?filter[reference]=MY_PRODUCT_REF&display=full&price[my_price][use_reduction]=1

But when I try to do this via my php script, the my_price isn't returned.

<?php
$ref = "";
$url = "";
$key = "";
define('DEBUG', true);			// Debug mode
define('PS_SHOP_PATH', $url);	// Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', $key);	// Auth key (Get it in your Back Office)
require_once('PSWebServiceLibrary.php');
try{
	$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
	$opt = array(
    	'resource' => 'products',
		'display' => 'full',
		'filter[reference]' => $ref,
		'price[my_price][use_tax]' => '1'
	);
	$xml = $webService->get($opt);
	$resources = $xml->children()->children();
}
catch (PrestaShopWebserviceException $e){
	// Here we are dealing with errors
	$trace = $e->getTrace();
	if ($trace[0]['args'][0] == 404) echo 'Bad ID';
	else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
	else 
		echo 'Other error : '.$e->getMessage().'<br>'; 
}
echo 'id '.$resources->product->id.'<br>';
echo 'my price '.$resources->product->my_price.'<br>';
?>

Do you have an idea ?

I think I don't call my request properly but I do not find the mistake.

Thanks

easyjava

easyjava

Hello,

I use the webservice to get some informations about a product. I need the final price so I use price[my_price][use_tax]=1 and it works very well with the url :

api/products/?filter[reference]=MY_PRODUCT_REF&display=full&price[my_price][use_reduction]=1

But when I try to do this via my php script, the my_price isn't returned.

<?php
$ref = "";
$url = "";
$key = "";
define('DEBUG', true);			// Debug mode
define('PS_SHOP_PATH', $url);	// Root path of your PrestaShop store
define('PS_WS_AUTH_KEY', $key);	// Auth key (Get it in your Back Office)
require_once('PSWebServiceLibrary.php');
try{
	$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
	$opt = array(
    	'resource' => 'products',
		'display' => 'full',
		'filter[reference]' => $ref,
		'price[my_price][use_tax]' => '1'
	);
	$xml = $webService->get($opt);
	$resources = $xml->children()->children();
}
catch (PrestaShopWebserviceException $e){
	// Here we are dealing with errors
	$trace = $e->getTrace();
	if ($trace[0]['args'][0] == 404) echo 'Bad ID';
	else if ($trace[0]['args'][0] == 401) echo 'Bad auth key';
	else 
		echo 'Other error : '.$e->getMessage().'<br>'; 
}
echo 'id '.$resources->product->id.'<br>';
echo 'my price '.$resources->product->my_price.'<br>';
?>

Do you have an idea ?

I think I don't call my request properly but I do not find the mistake.

Thanks

×
×
  • Create New...