Bonjour,
je suis entrain d'essayer de faire un script pour récuperer les données d'un catalog et en faire un fichier xml, sachant que je suis débutante en xml!!
Je touche au but mais j'ai un soucis au niveau des frais de port car je dois les calculer:
Cela fonctionne mais voila ce que j'ai en ouvrant le fichier xml generé:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 // Cout de la livraison if ( $products['products_weight'] <= 2 ){ $frais .= "11.36"; } elseif ( 2 < $products['products_weight'] && $products['products_weight'] <= 7 ){ $frais .= "16.15"; } elseif ( 7 < $products['products_weight'] && $products['products_weight'] <= 30 ){ $frais .= "26.91"; } elseif ( $products['products_weight'] > 30 ){ $frais .= " "; }
Il écrit tout à la suite.Mais si je déplace le code "cout de la livraison" il ne fait plus le calcul.*
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <frais_de_port>11.36</frais_de_port> ... <frais_de_port>11.36 11.36</frais_de_port> ... <frais_de_port>11.36 11.36 16.91</frais_de_port>
Voila un morceau de mon code:
Que dois-je faire?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 $special_query = tep_db_query("SELECT specials_new_products_price FROM " . TABLE_SPECIALS . " WHERE products_id = " . $products['products_id']); if ($special_result = tep_db_fetch_array($special_query)) $products['products_price'] = $special_result['specials_new_products_price']; $product_num++; echo '<produit num="'.$product_num.'">'."\n"; echo '<categorie><![CDATA['.$products['categories_name']. ']]></categorie>'; echo '<marque><![CDATA['.$products['manufacturers_name'].']]></marque>'; echo '<reference><![CDATA['. $products['products_model'] .']]></reference>'; echo '<refinterne><![CDATA['. $products['products_id'] .']]></refinterne>'; echo '<titre><![CDATA['. $products['products_name'] .']]></titre>'; echo '<description><![CDATA['. substr(strip_tags(str_replace(array('<BR>','<br>'), "</P>\n<P>",html_entity_decode($products['products_description']))),0,245) .'...]]></description>'; echo '<etat>Neuf</etat>'; echo '<poids>'.$products['products_weight'].'</poids>'; // Cout de la livraison if ( $products['products_weight'] <= 2 ){ $frais .= "11.36"; } elseif ( 2 < $products['products_weight'] && $products['products_weight'] <= 7 ){ $frais .= "16.15"; } elseif ( 7 < $products['products_weight'] && $products['products_weight'] <= 30 ){ $frais .= "26.91"; } elseif ( $products['products_weight'] > 30 ){ $frais .= " "; } echo '<frais_de_port><![CDATA['.$frais.']]></frais_de_port>'; echo '<stock>'.$products['products_quantity']. '</stock>';
Merci de votre aide
Partager