AcidLava Posted October 5, 2023 Share Posted October 5, 2023 (edited) Bonjour, Sur PS 1.7, j'essaye d'afficher la variable {$product.availability_message} d'un produit en fonction du stock, à savoir le message personnalisé sur les délais de livraison, dans le panier et sur la confirmation de commande à chaque ligne produit. Ça fonctionne sur le panier mais pas sur la confirmation de commande où j'insère cette variable dans order-confirmation-table.tpl. Voici mon code : {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)} <div> <span class="red icon--pulsing"></span> <span class="msg">{$product.availability_message}</span> </div> {else} <div> <span class="icon--pulsing"></span> <span class="msg">Disponible</span> </div> {/if} Quelqu'un saurait me dire comment y remédier ? Merci ! Edited October 5, 2023 by AcidLava (see edit history) Link to comment Share on other sites More sharing options...
wepresta Posted October 5, 2023 Share Posted October 5, 2023 1 hour ago, AcidLava said: Bonjour, Sur PS 1.7, j'essaye d'afficher la variable {$product.availability_message} d'un produit en fonction du stock, à savoir le message personnalisé sur les délais de livraison, dans le panier et sur la confirmation de commande à chaque ligne produit. Ça fonctionne sur le panier mais pas sur la confirmation de commande où j'insère cette variable dans order-confirmation-table.tpl. Voici mon code : {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)} <div> <span class="red icon--pulsing"></span> <span class="msg">{$product.availability_message}</span> </div> {else} <div> <span class="icon--pulsing"></span> <span class="msg">Disponible</span> </div> {/if} Quelqu'un saurait me dire comment y remédier ? Merci ! que dit {$product.availability_message|@var_dump} ? Link to comment Share on other sites More sharing options...
AcidLava Posted October 5, 2023 Author Share Posted October 5, 2023 @wepresta Merci pour votre retour. Ça affiche NULL Link to comment Share on other sites More sharing options...
AcidLava Posted October 5, 2023 Author Share Posted October 5, 2023 Je précise que {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)} n'est pas pris en compte non plus... Link to comment Share on other sites More sharing options...
wepresta Posted October 5, 2023 Share Posted October 5, 2023 (edited) 1 hour ago, AcidLava said: @wepresta Merci pour votre retour. Ça affiche NULL Ok donc juste cette variable n'est pas implémenté dans votre controller, suffit juste de l'ajouter dans OrderConfirmationController dans le initContent Edited October 5, 2023 by wepresta (see edit history) Link to comment Share on other sites More sharing options...
AcidLava Posted October 5, 2023 Author Share Posted October 5, 2023 @wepresta J'avoue que je ne suis pas très à l'aise avec ces fichiers, vous savez m'indiquer le code à intégrer pour {$product.availability_message} et {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)} ? En vous remerciant. Link to comment Share on other sites More sharing options...
wepresta Posted October 6, 2023 Share Posted October 6, 2023 (edited) 16 hours ago, AcidLava said: @wepresta J'avoue que je ne suis pas très à l'aise avec ces fichiers, vous savez m'indiquer le code à intégrer pour {$product.availability_message} et {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)} ? En vous remerciant. Je vois que les produits sont déjà envoyés sur le tpl Ducoup à l'intérieur de {foreach from=$products item=product} {/foreach} vous pouvez mettre votre {$product.availability_message} Edited October 6, 2023 by wepresta (see edit history) Link to comment Share on other sites More sharing options...
AcidLava Posted October 6, 2023 Author Share Posted October 6, 2023 (edited) @wepresta C'est ce que j'ai fais mais la variable n'affiche rien. {block name='order_confirmation_table'} {foreach from=$products item=product} <div class="order-line row"> <div class="col-sm-2 col-xs-3"> <span class="image"> {if !empty($product.default_image)} <img src="{$product.default_image.medium.url}" loading="lazy" /> {else} <img src="{$urls.no_picture_image.bySize.medium_default.url}" loading="lazy" /> {/if} </span> </div> <div class="col-sm-4 col-xs-9 details"> {if $add_product_link}<a href="{$product.url}" target="_blank">{/if} <span>{$product.name}</span> {if $add_product_link}</a>{/if} {if (isset($product.quantity_all_versions) && $product.quantity_all_versions < 0)} <div> <span class="red icon--pulsing"></span> <span class="msg">{$product.availability_message}</span> /div> {else} <div> <span class="icon--pulsing"></span> <span class="msg">{$product.availability_message}</span> </div> {/if} Edited October 6, 2023 by AcidLava (see edit history) Link to comment Share on other sites More sharing options...
wepresta Posted October 6, 2023 Share Posted October 6, 2023 Pouvez vous faire ceci dans le foreach et copiez sur le topic ce qu'il vous affiche : {$product|@var_dump} Link to comment Share on other sites More sharing options...
AcidLava Posted October 6, 2023 Author Share Posted October 6, 2023 (edited) Voici : array(122) { ["id_product"]=> string(4) "4917" ["id_supplier"]=> string(1) "0" ["id_manufacturer"]=> string(2) "26" ["id_category_default"]=> string(3) "111" ["id_shop_default"]=> string(1) "1" ["id_tax_rules_group"]=> string(1) "0" ["on_sale"]=> string(1) "0" ["online_only"]=> string(1) "0" ["ean13"]=> string(12) "093573548666" ["isbn"]=> string(0) "" ["upc"]=> string(0) "" ["mpn"]=> string(0) "" ["ecotax"]=> string(8) "0.000000" ["quantity"]=> string(1) "1" ["minimal_quantity"]=> string(1) "1" ["low_stock_threshold"]=> NULL ["low_stock_alert"]=> string(1) "0" ["price"]=> string(11) "199,00 €" ["wholesale_price"]=> string(10) "149.990000" ["unity"]=> string(0) "" ["unit_price_ratio"]=> string(8) "0.000000" ["additional_shipping_cost"]=> string(8) "0.000000" ["reference"]=> string(7) "8001864" ["supplier_reference"]=> string(0) "" ["location"]=> string(0) "" ["width"]=> string(8) "0.000000" ["height"]=> string(8) "0.000000" ["depth"]=> string(8) "0.000000" ["weight"]=> string(8) "3.000000" ["out_of_stock"]=> string(1) "2" ["additional_delivery_times"]=> string(1) "1" ["quantity_discount"]=> string(1) "0" ["customizable"]=> string(1) "0" ["uploadable_files"]=> string(1) "0" ["text_fields"]=> string(1) "0" ["active"]=> string(1) "1" ["redirect_type"]=> string(3) "404" ["id_type_redirected"]=> string(1) "0" ["available_for_order"]=> string(1) "1" ["available_date"]=> string(10) "0000-00-00" ["show_condition"]=> string(1) "0" ["condition"]=> string(3) "new" ["show_price"]=> string(1) "1" ["indexed"]=> string(1) "1" ["visibility"]=> string(4) "both" ["cache_is_pack"]=> string(1) "0" ["cache_has_attachments"]=> string(1) "0" ["is_virtual"]=> string(1) "0" ["cache_default_attribute"]=> string(1) "0" ["date_add"]=> string(19) "2023-04-23 17:56:02" ["date_upd"]=> string(19) "2023-09-06 11:50:41" ["advanced_stock_management"]=> string(1) "0" ["pack_stock_type"]=> string(1) "3" ["state"]=> string(1) "1" ["product_type"]=> string(0) "" ["id_shop"]=> string(1) "1" ["id_order_detail"]=> string(5) "28829" ["id_order"]=> string(5) "11633" ["id_order_invoice"]=> string(5) "11543" ["id_warehouse"]=> string(1) "0" ["product_id"]=> string(4) "4917" ["product_attribute_id"]=> string(1) "0" ["id_customization"]=> string(1) "0" ["product_name"]=> string(28) "Kit de démarrage Cricut joy" ["product_quantity"]=> string(1) "1" ["product_quantity_in_stock"]=> string(2) "-1" ["product_quantity_refunded"]=> string(1) "0" ["product_quantity_return"]=> string(1) "0" ["product_quantity_reinjected"]=> string(1) "0" ["product_price"]=> float(199) ["reduction_percent"]=> string(4) "0.00" ["reduction_amount"]=> string(8) "0.000000" ["reduction_amount_tax_incl"]=> string(8) "0.000000" ["reduction_amount_tax_excl"]=> string(8) "0.000000" ["group_reduction"]=> string(4) "0.00" ["product_quantity_discount"]=> string(8) "0.000000" ["product_ean13"]=> string(12) "093573548666" ["product_isbn"]=> string(0) "" ["product_upc"]=> string(0) "" ["product_mpn"]=> string(0) "" ["product_reference"]=> string(7) "8001864" ["product_supplier_reference"]=> string(0) "" ["product_weight"]=> string(8) "3.000000" ["tax_computation_method"]=> string(1) "0" ["tax_name"]=> string(0) "" ["tax_rate"]=> float(0) ["ecotax_tax_rate"]=> string(5) "0.000" ["discount_quantity_applied"]=> string(1) "0" ["download_hash"]=> string(0) "" ["download_nb"]=> string(1) "0" ["download_deadline"]=> string(19) "0000-00-00 00:00:00" ["total_price_tax_incl"]=> string(10) "199.000000" ["total_price_tax_excl"]=> string(10) "199.000000" ["unit_price_tax_incl"]=> string(10) "199.000000" ["unit_price_tax_excl"]=> string(10) "199.000000" ["total_shipping_price_tax_incl"]=> string(8) "0.000000" ["total_shipping_price_tax_excl"]=> string(8) "0.000000" ["purchase_supplier_price"]=> string(10) "149.990000" ["original_product_price"]=> string(10) "199.000000" ["original_wholesale_price"]=> string(10) "149.990000" ["total_refunded_tax_excl"]=> string(8) "0.000000" ["total_refunded_tax_incl"]=> string(8) "0.000000" ["image"]=> object(Image)#1019 (29) { ["id"]=> int(7229) ["id_image"]=> string(4) "7229" ["id_product"]=> string(4) "4917" ["position"]=> string(1) "3" ["cover"]=> string(1) "1" ["legend"]=> array(1) { [1]=> string(28) "Kit de démarrage Cricut joy" } ["image_format"]=> string(3) "jpg" ["source_index"]=> string(42) "/home/wexw8528/public_html/img/p/index.php" ["folder":protected]=> NULL ["existing_path":protected]=> NULL ["id_lang":protected]=> NULL ["id_shop":protected]=> int(1) ["id_shop_list"]=> array(0) { } ["get_shop_from_context":protected]=> bool(true) ["table":protected]=> string(5) "image" ["identifier":protected]=> string(8) "id_image" ["fieldsRequired":protected]=> array(1) { [0]=> string(10) "id_product" } ["fieldsSize":protected]=> array(0) { } ["fieldsValidate":protected]=> array(3) { ["id_product"]=> string(12) "isUnsignedId" ["position"]=> string(13) "isUnsignedInt" ["cover"]=> string(6) "isBool" } ["fieldsRequiredLang":protected]=> array(0) { } ["fieldsSizeLang":protected]=> array(1) { ["legend"]=> int(128) } ["fieldsValidateLang":protected]=> array(1) { ["legend"]=> string(13) "isGenericName" } ["tables":protected]=> array(0) { } ["webserviceParameters":protected]=> array(0) { } ["image_dir":protected]=> string(33) "/home/wexw8528/public_html/img/p/" ["translator":protected]=> NULL ["def":protected]=> array(6) { ["table"]=> string(5) "image" ["primary"]=> string(8) "id_image" ["multilang"]=> bool(true) ["fields"]=> array(4) { ["id_product"]=> array(4) { ["type"]=> int(1) ["shop"]=> string(4) "both" ["validate"]=> string(12) "isUnsignedId" ["required"]=> bool(true) } ["position"]=> array(2) { ["type"]=> int(1) ["validate"]=> string(13) "isUnsignedInt" } ["cover"]=> array(4) { ["type"]=> int(2) ["allow_null"]=> bool(true) ["validate"]=> string(6) "isBool" ["shop"]=> bool(true) } ["legend"]=> array(4) { ["type"]=> int(3) ["lang"]=> bool(true) ["validate"]=> string(13) "isGenericName" ["size"]=> int(128) } } ["classname"]=> string(5) "Image" ["associations"]=> array(1) { ["l"]=> array(3) { ["type"]=> int(2) ["field"]=> string(8) "id_image" ["foreign_field"]=> string(8) "id_image" } } } ["update_fields":protected]=> NULL ["force_id"]=> bool(false) } ["image_size"]=> NULL ["current_stock"]=> int(0) ["tax_calculator"]=> object(TaxCalculator)#1017 (2) { ["taxes"]=> array(0) { } ["computation_method"]=> int(1) } ["product_price_wt"]=> float(199) ["product_price_wt_but_ecotax"]=> float(199) ["total_wt"]=> string(10) "199.000000" ["total_price"]=> string(10) "199.000000" ["customizedDatas"]=> NULL ["customizationQuantityTotal"]=> int(0) ["id_address_delivery"]=> string(4) "7819" ["name"]=> string(28) "Kit de démarrage Cricut joy" ["id_product_attribute"]=> string(1) "0" ["total"]=> string(11) "199,00 €" ["attributes"]=> array(0) { } ["cover"]=> array(9) { ["bySize"]=> array(5) { ["small_default"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-small_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(78) ["height"]=> int(101) } ["cart_default"]=> array(3) { ["url"]=> string(77) "https://www.xxx.com/7229-cart_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(114) ["height"]=> int(148) } ["home_default"]=> array(3) { ["url"]=> string(77) "https://www.xxx.com/7229-home_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(297) ["height"]=> int(386) } ["medium_default"]=> array(3) { ["url"]=> string(79) "https://www.xxx.com/7229-medium_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(435) ["height"]=> int(520) } ["large_default"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-large_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(870) ["height"]=> int(1131) } } ["small"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-small_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(78) ["height"]=> int(101) } ["medium"]=> array(3) { ["url"]=> string(77) "https://www.xxx.com/7229-home_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(297) ["height"]=> int(386) } ["large"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-large_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(870) ["height"]=> int(1131) } ["legend"]=> string(28) "Kit de démarrage Cricut joy" ["id_image"]=> string(4) "7229" ["cover"]=> string(1) "1" ["position"]=> string(1) "3" ["associatedVariants"]=> array(0) { } } ["default_image"]=> array(9) { ["bySize"]=> array(5) { ["small_default"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-small_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(78) ["height"]=> int(101) } ["cart_default"]=> array(3) { ["url"]=> string(77) "https://www.xxx.com/7229-cart_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(114) ["height"]=> int(148) } ["home_default"]=> array(3) { ["url"]=> string(77) "https://www.xxx.com/7229-home_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(297) ["height"]=> int(386) } ["medium_default"]=> array(3) { ["url"]=> string(79) "https://www.xxx.com/7229-medium_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(435) ["height"]=> int(520) } ["large_default"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-large_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(870) ["height"]=> int(1131) } } ["small"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-small_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(78) ["height"]=> int(101) } ["medium"]=> array(3) { ["url"]=> string(77) "https://www.xxx.com/7229-home_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(297) ["height"]=> int(386) } ["large"]=> array(3) { ["url"]=> string(78) "https://www.xxx.com/7229-large_default/kit-de-demarrage-cricut-joy.jpg" ["width"]=> int(870) ["height"]=> int(1131) } ["legend"]=> string(28) "Kit de démarrage Cricut joy" ["id_image"]=> string(4) "7229" ["cover"]=> string(1) "1" ["position"]=> string(1) "3" ["associatedVariants"]=> array(0) { } } ["unit_price_full"]=> string(0) "" ["qty_returned"]=> string(1) "0" ["customizations"]=> array(0) { } } Edited October 6, 2023 by AcidLava (see edit history) Link to comment Share on other sites More sharing options...
wepresta Posted October 6, 2023 Share Posted October 6, 2023 Re, J'ai vérifié cela de plus près, et en effet, "availability_message" est instancié avec "ProductLazyArray" et "ProductPresenter". Il serait donc nécessaire d'instancier la liste de produits de la même manière dans le contrôleur "orderConfirmationController", car actuellement elle est instanciée avec "$order->getProducts()" et c'est là que "$availability_message" ne se trouve pas. Cela peut être un peu compliqué à mettre en place pour un débutant. 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