agarmur Posted June 20, 2022 Share Posted June 20, 2022 Bonjour, je suis créer un webservice pour pouvoir créer des produits, je chercher un moyen de mettre une tax par rapport à un nombre données, dans un produit il y a une fonction tax_rate, quand je l'implémente $product->tax_rate = 10; et que par la suite je echo $product->getTaxesRate(); Il me renvoie : 0 Voici mon code complet : $xml = simplexml_load_file('php://input'); $product = new Product($xml->id); $product->category = [2, 3]; $product->id_category_default = (int)$xml->id_category_default; $product->name = $xml->name; $product->price = $xml->price; //prix $product->unit_price = $xml->unit_price; //prix unitaire $product->wholesale_price = $xml->wholesale_price; //prix de gros $product->ecotax = $xml->ecotax; $product->ean13 = $xml->ean13; //code barre $product->tax_rate = 30; $product->description = html_entity_decode($xml->description); $product->description_short = html_entity_decode($xml->description_short); $product->reference = $xml->reference; $product->weight = $xml->weight; //poids $product->height = $xml->height; //hauteur $product->width = $xml->width; //largeur $product->depth = $xml->depth; //profondeur $product->minimal_quantity = (int)$xml->minimal_quantity; // quantité minimal $product->available_date = $xml->available_date; $product->delivery_in_stock = $xml->delivery_in_stock; $product->delivery_out_stock = $xml->delivery_out_stock; $product->additional_shipping_cost = $xml->shipping_cost; $product->id_manufacturer = 1; $product->manufacturer_name = $xml->manufacturer_name; $product->indexed = 1; $product->redirect_type = '301'; $product->active = true; if ($xml->online_only == "true") { $product->online_only = true; } else { $product->online_only = false; } if ($xml->available_for_order == "true") { $product->available_for_order = true; } else { $product->available_for_order = false; } if ($xml->show_price == "true") { $product->show_price = true; } else { $product->show_price = false; } $product->save(); $product->updateCategories($product->category); // STOCK $e = $product->getDefaultIdProductAttribute(); StockAvailable::setQuantity($product->id, $e, $xml->quantity); //IMAGE $nb = count($xml->urlImage) - 1; $i = 0; $a = 1; while ($i <= $nb) { $image = new Image(); $image->id_product = $product->id; $image->position = Image::getHighestPosition($product->id) + $a++; if ($i >= 1) { $image->cover = false; } else { $image->cover = true; } $image->image_format = 'jpg'; $image->save(); $this->copyImg((int)$product->id, (int)$image->id, ($xml->urlImage[$i++]), 'products', false); } //SET CARRIER Db::getInstance()->execute('INSERT INTO `ps_product_carrier` (`id_product`, `id_carrier_reference`, `id_shop`) VALUES (' . $product->id . ', ' . $xml->idCarrier . ', ' . (int)Context::getContext()->shop->id . ');'); echo $product->getTaxesRate(); Merci d'avance ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now