[Skip to main content](#vessel-content)

#   Récupérer prices\[ \] dans hikashop\_quantity\_render

##

- **[Flooder](/forum/user/23280-flooder "View Flooder's Profile")**
- [![Flooder's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar23280.png)](/forum/user/23280-flooder "View Flooder's Profile") Topic Author
- [ Offline](/forum/user/23280-flooder)

Less More

- Posts: 263
- Thank you received: 11
-
-

13 years 2 months ago [\#117063](#117063) by [Flooder](/forum/user/23280-flooder "View Flooder's Profile")  *[Récupérer prices\[ \] dans hikashop\_quantity\_render](/forum/5-support-en-francais-french-support-/860628-recuperer-prices-dans-hikashop-quantity-render#117063 "Bonjour à tous,  Je suis en train de créer une nouvelle fonction hikashop&#95;quantity&#95;render($html,$i,$max&#95;quantity,$min&#95;quantity) dans le fichier /templates/.../html/hikashop&#95;button.php.  Je pensais pouvoir accéder au tableau des prix de mon produit avec $this-&gt;row-&gt;prices&#91;&#93; mais cette variable ne semble pas fonctionner dans /templates/.../html/hikashop&#95;button.php.  Dois-je absolument accéder au prix de mon produit en faisant une requête à la base de données? Ne pourrais-je pas utiliser simplement une variable?  Merci (encore)")* was created by *[Flooder](/forum/user/23280-flooder "View Flooder's Profile")*

Bonjour à tous,

Je suis en train de créer une nouvelle fonction hikashop_quantity_render($html,$i,$max_quantity,$min_quantity) dans le fichier /templates/.../html/hikashop_button.php.

Je pensais pouvoir accéder au tableau des prix de mon produit avec $this-&gt;row-&gt;prices[] mais cette variable ne semble pas fonctionner dans /templates/.../html/hikashop_button.php.

Dois-je absolument accéder au prix de mon produit en faisant une requête à la base de données? Ne pourrais-je pas utiliser simplement une variable?

Merci (encore)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vODYwNjI4LXJlY3VwZXJlci1wcmljZXMtZGFucy1oaWthc2hvcC1xdWFudGl0eS1yZW5kZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Flooder](/forum/user/23280-flooder "View Flooder's Profile")**
- [![Flooder's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar23280.png)](/forum/user/23280-flooder "View Flooder's Profile") Topic Author
- [ Offline](/forum/user/23280-flooder)

Less More

- Posts: 263
- Thank you received: 11
-
-

13 years 2 months ago [\#117087](#117087) by [Flooder](/forum/user/23280-flooder "View Flooder's Profile")  Replied by *[Flooder](/forum/user/23280-flooder "View Flooder's Profile")* on topic *[Récupérer prices\[ \] dans hikashop\_quantity\_render](/forum/5-support-en-francais-french-support-/860628-recuperer-prices-dans-hikashop-quantity-render#117087 "Bonjour à tous,  Je suis en train de créer une nouvelle fonction hikashop&#95;quantity&#95;render($html,$i,$max&#95;quantity,$min&#95;quantity) dans le fichier /templates/.../html/hikashop&#95;button.php.  Je pensais pouvoir accéder au tableau des prix de mon produit avec $this-&gt;row-&gt;prices&#91;&#93; mais cette variable ne semble pas fonctionner dans /templates/.../html/hikashop&#95;button.php.  Dois-je absolument accéder au prix de mon produit en faisant une requête à la base de données? Ne pourrais-je pas utiliser simplement une variable?  Merci (encore)")*

Voici où j'en suis maintenant pour récupérer le tableau des prix d'un produit dans /templates/.../html/hikashop_button.php.

Si je réussis à faire fonctionner jusqu'à print_r($productRows), je pourrai terminer. Mais ça ne fonctionne pas. Il y a une erreur avant le print_r, mais je ne vois pas ce qui cloche.

Pouvez-vous m'aider?

Code:

&lt;?php function hikashop_quantity_render($html,$i,$max_quantity,$min_quantity){ $class = hikashop_get('class.currency'); $zone = hikashop_getZone(); echo "zone".$zone."&lt;br /&gt;"; $currency = hikashop_getCurrency(); echo "currency". $currency."&lt;br /&gt;"; $product_id = hikashop_getCID(); echo "id du produit". $product_id."&lt;br /&gt;"; $query= 'SELECT * FROM '.hikashop_table('product').' WHERE product_id='.$product_id; $myDatabase-&gt;setQuery($query); $result = $myDatabase-&gt;query(); $productRows = $myDatabase-&gt;loadObjectList(); $class-&gt;getListingPrices($productRows, $zone, $currency ); print_r($productRows); /*À terminer return ' &lt;input type="radio" name="group2" value="Q1"&gt; Quantité 1&lt;br&gt; &lt;input type="radio" name="group2" value="Q2" checked&gt;Quantité 2&lt;br /&gt;'.$html; À terminer */ } ?&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vODYwNjI4LXJlY3VwZXJlci1wcmljZXMtZGFucy1oaWthc2hvcC1xdWFudGl0eS1yZW5kZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86320
- Thank you received: 14276
-
-

13 years 2 months ago [\#117108](#117108) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Récupérer prices\[ \] dans hikashop\_quantity\_render](/forum/5-support-en-francais-french-support-/860628-recuperer-prices-dans-hikashop-quantity-render#117108 "Bonjour à tous,  Je suis en train de créer une nouvelle fonction hikashop&#95;quantity&#95;render($html,$i,$max&#95;quantity,$min&#95;quantity) dans le fichier /templates/.../html/hikashop&#95;button.php.  Je pensais pouvoir accéder au tableau des prix de mon produit avec $this-&gt;row-&gt;prices&#91;&#93; mais cette variable ne semble pas fonctionner dans /templates/.../html/hikashop&#95;button.php.  Dois-je absolument accéder au prix de mon produit en faisant une requête à la base de données? Ne pourrais-je pas utiliser simplement une variable?  Merci (encore)")*

Bonjour,

C'est la bonne méthode en effet.
Il faut que vous enleviez la ligne:
$result = $myDatabase-&gt;query();

Sinon, la ligne d'après ne renverra rien.

The following user(s) said Thank You: [Flooder](/forum/user/23280-flooder "View Flooder's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vODYwNjI4LXJlY3VwZXJlci1wcmljZXMtZGFucy1oaWthc2hvcC1xdWFudGl0eS1yZW5kZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Flooder](/forum/user/23280-flooder "View Flooder's Profile")**
- [![Flooder's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar23280.png)](/forum/user/23280-flooder "View Flooder's Profile") Topic Author
- [ Offline](/forum/user/23280-flooder)

Less More

- Posts: 263
- Thank you received: 11
-
-

13 years 2 months ago -  13 years 2 months ago [\#117142](#117142) by [Flooder](/forum/user/23280-flooder "View Flooder's Profile")  Replied by *[Flooder](/forum/user/23280-flooder "View Flooder's Profile")* on topic *[Récupérer prices\[ \] dans hikashop\_quantity\_render](/forum/5-support-en-francais-french-support-/860628-recuperer-prices-dans-hikashop-quantity-render#117142 "Bonjour à tous,  Je suis en train de créer une nouvelle fonction hikashop&#95;quantity&#95;render($html,$i,$max&#95;quantity,$min&#95;quantity) dans le fichier /templates/.../html/hikashop&#95;button.php.  Je pensais pouvoir accéder au tableau des prix de mon produit avec $this-&gt;row-&gt;prices&#91;&#93; mais cette variable ne semble pas fonctionner dans /templates/.../html/hikashop&#95;button.php.  Dois-je absolument accéder au prix de mon produit en faisant une requête à la base de données? Ne pourrais-je pas utiliser simplement une variable?  Merci (encore)")*

Et voilà! Ça fonctionne au poil.

&lt;?php
Code:

function hikashop_quantity_render($html,$i,$max_quantity,$min_quantity){ $db = JFactory::getDBO(); $class = hikashop_get('class.currency'); $zone = hikashop_getZone(); echo "zone".$zone."&lt;br /&gt;"; $currency = hikashop_getCurrency(); echo "currency". $currency."&lt;br /&gt;"; $product_id = hikashop_getCID(); echo "id du produit". $product_id."&lt;br /&gt;"; $query= 'SELECT * FROM '.hikashop_table('product').' WHERE product_id='.$product_id; $db-&gt;setQuery($query); //$result = $myDatabase-&gt;query(); $productRows = $db-&gt;loadObjectList(); $class-&gt;getListingPrices($productRows, $zone, $currency ); print_r($productRows); }

Last edit: 13 years 2 months ago by [Flooder](/forum/user/23280-flooder "View Flooder's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vODYwNjI4LXJlY3VwZXJlci1wcmljZXMtZGFucy1oaWthc2hvcC1xdWFudGl0eS1yZW5kZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Flooder](/forum/user/23280-flooder "View Flooder's Profile")**
- [![Flooder's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar23280.png)](/forum/user/23280-flooder "View Flooder's Profile") Topic Author
- [ Offline](/forum/user/23280-flooder)

Less More

- Posts: 263
- Thank you received: 11
-
-

13 years 2 months ago -  13 years 2 months ago [\#117146](#117146) by [Flooder](/forum/user/23280-flooder "View Flooder's Profile")  Replied by *[Flooder](/forum/user/23280-flooder "View Flooder's Profile")* on topic *[Récupérer prices\[ \] dans hikashop\_quantity\_render](/forum/5-support-en-francais-french-support-/860628-recuperer-prices-dans-hikashop-quantity-render#117146 "Bonjour à tous,  Je suis en train de créer une nouvelle fonction hikashop&#95;quantity&#95;render($html,$i,$max&#95;quantity,$min&#95;quantity) dans le fichier /templates/.../html/hikashop&#95;button.php.  Je pensais pouvoir accéder au tableau des prix de mon produit avec $this-&gt;row-&gt;prices&#91;&#93; mais cette variable ne semble pas fonctionner dans /templates/.../html/hikashop&#95;button.php.  Dois-je absolument accéder au prix de mon produit en faisant une requête à la base de données? Ne pourrais-je pas utiliser simplement une variable?  Merci (encore)")*

Ma liste déroulante fonctionne maintenant. Le client ne peut acheter que les quantités minimales pour chaque prix.

En voici le contenu actuel de mon fichier templates/../html/hikashop_button.php :
Code:

function hikashop_quantity_render($html,$i,$max_quantity,$min_quantity){ $db = JFactory::getDBO(); $class = hikashop_get('class.currency'); $zone = hikashop_getZone(); $currency = hikashop_getCurrency(); $product_id = hikashop_getCID(); $query= 'SELECT * FROM '.hikashop_table('product').' WHERE product_id='.$product_id; $db-&gt;setQuery($query); $productRows = $db-&gt;loadObjectList(); $class-&gt;getListingPrices($productRows, $zone, $currency ); $first = 0; $chaine = '&lt;select id="hikashop_product_quantity_field" name="quantity"&gt;'; $tableau = array(); foreach ($productRows[0]-&gt;prices as $price) { $min = $price-&gt;price_min_quantity; if ($min == 0) $min = 1; $tableau[] = $min; } asort($tableau); foreach ($tableau as $num) { $chaine .= '&lt;option value="' . $num . '"&gt;' . $num . '&lt;/option&gt;'; } $chaine .= '&lt;/select&gt;'; return $chaine . $html; }

Last edit: 13 years 2 months ago by [Flooder](/forum/user/23280-flooder "View Flooder's Profile"). Reason: J'ai trouvé une petite coquille... C'est corrigé!

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vODYwNjI4LXJlY3VwZXJlci1wcmljZXMtZGFucy1oaWthc2hvcC1xdWFudGl0eS1yZW5kZXI/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.081 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
