Bonjour,
J'ai un prestashop 1.7.8.11 ainsi que PHP 7.4.
En mode debug je trouve quelques erreurs de type :
ContextErrorException
Notice: Trying to access array offset on value of type null
Par exemple au moment de payer une commande, j'ai une erreur de ce type, liée au fichier "order-confirmation-table.tpl" qui est celui-ci :
<div id="order-items" class=""> <div class="row"> {block name='order_items_table_head'} <h3 class="table__title-head col-md-6 col-12">{l s='Order items' d='Shop.Theme.Checkout'}</h3> <h3 class="table__title-head col-md-2 text-md-center _desktop-title">{l s='Unit price' d='Shop.Theme.Checkout'}</h3> <h3 class="table__title-head col-md-2 text-md-center _desktop-title">{l s='Quantity' d='Shop.Theme.Checkout'}</h3> <h3 class="table__title-head col-md-2 text-md-center _desktop-title">{l s='Total products' d='Shop.Theme.Checkout'}</h3> {/block} </div> <div class="order-confirmation-table"> {block name='order_confirmation_table'} {foreach from=$products item=product} <div class="order-line row"> <div class="col-sm-2 col-3"> <span class="image"> <img src="{$product.cover.medium.url}" class="img-fluid"/> </span> </div> <div class="col-sm-4 col-9 details"> {if $add_product_link}<a href="{$product.url}" target="_blank">{/if} <span>{$product.name}</span> {if $add_product_link}</a>{/if} {if is_array($product.customizations) && $product.customizations|count} {foreach from=$product.customizations item="customization"} <div class="customizations"> <a href="#" data-toggle="modal" data-target="#product-customizations-modal-{$customization.id_customization}">{l s='Product customization' d='Shop.Theme.Catalog'}</a> </div> <div class="modal fade customization-modal" id="product-customizations-modal-{$customization.id_customization}" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">{l s='Product customization' d='Shop.Theme.Catalog'}</h4> </div> <div class="modal-body"> {foreach from=$customization.fields item="field"} <div class="product-customization-line row"> <div class="col-sm-3 col-4 label"> {$field.label} </div> <div class="col-sm-9 col-8 value"> {if $field.type == 'text'} {if (int)$field.id_module} {$field.text nofilter} {else} {$field.text} {/if} {elseif $field.type == 'image'} <img src="{$field.image.small.url}"> {/if} </div> </div> {/foreach} </div> </div> </div> </div> {/foreach} {/if} {hook h='displayProductPriceBlock' product=$product type="unit_price"} </div> <div class="col-sm-6 col-12 qty"> <div class="row"> <div class="col-4 text-sm-center text-left">{$product.price}</div> <div class="col-4 text-sm-center">{$product.quantity}</div> <div class="col-4 text-sm-center text-right bold">{$product.total}</div> </div> </div> </div> {/foreach} <hr> <table class="table table-borderless table-sm mb-0"> {foreach $subtotals as $subtotal} {if $subtotal.type !== 'tax' && $subtotal.label !== null} <tr> <td>{$subtotal.label}</td> <td class="text-right">{if 'discount' == $subtotal.type}- {/if}{$subtotal.value}</td> </tr> {/if} {/foreach} {if !$configuration.display_prices_tax_incl && $configuration.taxes_enabled} <tr> <td><span class="text-uppercase">{$totals.total.label} {$labels.tax_short}</span></td> <td class="text-right">{$totals.total.value}</td> </tr> <tr class="total-value font-weight-bold"> <td><span class="text-uppercase">{$totals.total_including_tax.label}</span></td> <td class="text-right">{$totals.total_including_tax.value}</td> </tr> {else} <tr class="total-value font-weight-bold"> <td><span class="text-uppercase">{$totals.total.label} {if $configuration.taxes_enabled}{$labels.tax_short}{/if}</span></td> <td class="text-right">{$totals.total.value}</td> </tr> {/if} {if $subtotals.tax.label !== null} <tr class="sub taxes"> <td class="small"><span class="label">{l s='%label%:' sprintf=['%label%' => $subtotals.tax.label] d='Shop.Theme.Global'}</span> <span class="value">{$subtotals.tax.value}</span></td> </tr> {/if} </table> {/block} </div> </div>
Voici la version modifiée avec des "IF" et des "ISSET", je voulais savoir si les modifications vous paraissent OK, ou si certaine sont superflues voir nuisibles (je n'ai plus d'erreur mais je ne suis pas spécialiste) :
<div id="order-items" class=""> <div class="row"> {block name='order_items_table_head'} <h3 class="table__title-head col-md-6 col-12">{l s='Order items' d='Shop.Theme.Checkout'}</h3> <h3 class="table__title-head col-md-2 text-md-center _desktop-title">{l s='Unit price' d='Shop.Theme.Checkout'}</h3> <h3 class="table__title-head col-md-2 text-md-center _desktop-title">{l s='Quantity' d='Shop.Theme.Checkout'}</h3> <h3 class="table__title-head col-md-2 text-md-center _desktop-title">{l s='Total products' d='Shop.Theme.Checkout'}</h3> {/block} </div> <div class="order-confirmation-table"> {block name='order_confirmation_table'} {foreach from=$products item=product} <div class="order-line row"> <div class="col-sm-2 col-3"> <span class="image"> {if isset($product.cover.medium.url)} <img src="{$product.cover.medium.url}" class="img-fluid"/> {/if} </span> </div> <div class="col-sm-4 col-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.customizations) && is_array($product.customizations) && count($product.customizations)} {foreach from=$product.customizations item="customization"} <div class="customizations"> <a href="#" data-toggle="modal" data-target="#product-customizations-modal-{$customization.id_customization}">{l s='Product customization' d='Shop.Theme.Catalog'}</a> </div> <div class="modal fade customization-modal" id="product-customizations-modal-{$customization.id_customization}" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> <h4 class="modal-title">{l s='Product customization' d='Shop.Theme.Catalog'}</h4> </div> <div class="modal-body"> {foreach from=$customization.fields item="field"} <div class="product-customization-line row"> <div class="col-sm-3 col-4 label"> {if isset($field.label)}{$field.label}{/if} </div> <div class="col-sm-9 col-8 value"> {if isset($field.type) && $field.type == 'text'} {if (int)$field.id_module} {$field.text nofilter} {else} {$field.text} {/if} {elseif isset($field.type) && $field.type == 'image'} {if isset($field.image.small.url)} <img src="{$field.image.small.url}"> {/if} {/if} </div> </div> {/foreach} </div> </div> </div> </div> {/foreach} {/if} {hook h='displayProductPriceBlock' product=$product type="unit_price"} </div> <div class="col-sm-6 col-12 qty"> <div class="row"> <div class="col-4 text-sm-center text-left">{$product.price}</div> <div class="col-4 text-sm-center">{$product.quantity}</div> <div class="col-4 text-sm-center text-right bold">{$product.total}</div> </div> </div> </div> {/foreach} <hr> <table class="table table-borderless table-sm mb-0"> {foreach $subtotals as $subtotal} {if isset($subtotal.type) && $subtotal.type !== 'tax' && isset($subtotal.label) && $subtotal.label !== null} <tr> <td>{$subtotal.label}</td> <td class="text-right">{if 'discount' == $subtotal.type}- {/if}{$subtotal.value}</td> </tr> {/if} {/foreach} {if !$configuration.display_prices_tax_incl && $configuration.taxes_enabled} <tr> <td><span class="text-uppercase">{$totals.total.label} {$labels.tax_short}</span></td> <td class="text-right">{$totals.total.value}</td> </tr> <tr class="total-value font-weight-bold"> <td><span class="text-uppercase">{$totals.total_including_tax.label}</span></td> <td class="text-right">{$totals.total_including_tax.value}</td> </tr> {else} <tr class="total-value font-weight-bold"> <td><span class="text-uppercase">{$totals.total.label} {if $configuration.taxes_enabled}{$labels.tax_short}{/if}</span></td> <td class="text-right">{$totals.total.value}</td> </tr> {/if} {if isset($subtotals.tax.label) && $subtotals.tax.label !== null} <tr class="sub taxes"> <td class="small"><span class="label">{l s='%label%:' sprintf=['%label%' => $subtotals.tax.label] d='Shop.Theme.Global'}</span> <span class="value">{$subtotals.tax.value}</span></td> </tr> {/if} </table> {/block} </div> </div>
Merci pour vos retours.