Mursik Posted September 17, 2020 Report Share Posted September 17, 2020 (edited) Доброго времени суток! Столкнулся с проблемой когда добавляешь товар в корзину и нажимаешь кнопку оплатить , то вылазеют ошибки. Данная тема не является дубликатом прям точь в точь идентичными, так все способы из данных форумов не помогли. Warning: Invalid argument supplied for foreach() in/home/c/co06646/new/public_html/view/CartView.php on line 99Warning: Cannot modify header information - headers already sent by (output started at /home/c/co06646/new/public_html/view/CartView.php:99) in/home/c/co06646/new/public_html/view/CartView.php on line 121Warning: Cannot modify header information - headers already sent by (output started at /home/c/co06646/new/public_html/view/CartView.php:99) in/home/c/co06646/new/public_html/index.php on line 33 CartView.php // Если нажали оформить заказ if(isset($_POST['checkout'])) { $order = new stdClass; $order->delivery_id = $this->request->post('delivery_id', 'integer'); $order->name = $this->request->post('name'); $order->email = $this->request->post('email'); //$order->address = $this->request->post('address'); $order->phone = $this->request->post('phone'); $order->comment = $this->request->post('comment'); $order->ip = $_SERVER['REMOTE_ADDR']; $this->design->assign('delivery_id', $order->delivery_id); $this->design->assign('name', $order->name); $this->design->assign('email', $order->email); $this->design->assign('phone', $order->phone); //$this->design->assign('address', $order->address); $captcha_code = $this->request->post('captcha_code', 'string'); Так же прикрепляю полностью файл . CartView.php Edited September 17, 2020 by Mursik Quote Link to post Share on other sites
Noxter Posted September 17, 2020 Report Share Posted September 17, 2020 cart.tpl Quote Link to post Share on other sites
Mursik Posted September 18, 2020 Author Report Share Posted September 18, 2020 cart.tpl {* Шаблон корзины *} {$meta_title = "Корзина" scope=parent} <ul class="breadcrumbs" aria-label="Breadcrumb" role="navigation"> <li class="breadcrumbs__item"><a href="/">Главная</a></li> <li class="breadcrumbs__item"><a href="/cart">Избранное</a></li> </ul> {if $cart->purchases} <form method="post" name="cart"> {* Список покупок *} <table id="purchases"> {foreach $cart->purchases as $purchase} <tr> {* Изображение товара *} <td class="image"> {$image = $purchase->product->images|first} {if $image} <a href="products/{$purchase->product->url}"><img src="{$image->filename|resize:150:150}" alt="{$product->name|escape}"></a> {/if} </td> {* Название товара *} <td class="name"> <a href="products/{$purchase->product->url}">{$purchase->product->name|escape}</a> <br> {$purchase->variant->name|escape} </td> {* Цена за единицу *} <td class="price"> {($purchase->variant->price)|convert} {$currency->sign} </td> {* Количество <td class="amount"> <select name="amounts[{$purchase->variant->id}]" onchange="document.cart.submit();"> {section name=amounts start=1 loop=$purchase->variant->stock+1 step=1} <option value="{$smarty.section.amounts.index}" {if $purchase->amount==$smarty.section.amounts.index}selected{/if}>{$smarty.section.amounts.index} {$settings->units}</option> {/section} </select> </td> *} {* <td class="amount" style="text-align: right"> <div class="field-select" style="margin-bottom: 0"> <select style="padding-top: 0; padding-bottom: 0; width: 70px;" class="field-select__select" name="amounts[{$purchase->variant->id}]" onchange="document.cart.submit();"> {section name=amounts start=1 loop=$purchase->variant->stock+1 step=1} <option value="{$smarty.section.amounts.index}" {if $purchase->amount==$smarty.section.amounts.index}selected{/if}>{$smarty.section.amounts.index} {$settings->units}</option> {/section} </select> </div> </td>*} {* Цена *} {*<td class="price"> {($purchase->variant->price*$purchase->amount)|convert} {$currency->sign} </td>*} {* Удалить из корзины *} <td class="remove" style="text-align: right;"> <a href="cart/remove/{$purchase->variant->id}" style="margin-right: 20px;"> <svg xmlns="http://www.w3.org/2000/svg" height="18pt" viewBox="-47 0 512 512" width="18pt"><path d="m416.875 114.441406-11.304688-33.886718c-4.304687-12.90625-16.339843-21.578126-29.941406-21.578126h-95.011718v-30.933593c0-15.460938-12.570313-28.042969-28.027344-28.042969h-87.007813c-15.453125 0-28.027343 12.582031-28.027343 28.042969v30.933593h-95.007813c-13.605469 0-25.640625 8.671876-29.945313 21.578126l-11.304687 33.886718c-2.574219 7.714844-1.2695312 16.257813 3.484375 22.855469 4.753906 6.597656 12.445312 10.539063 20.578125 10.539063h11.816406l26.007813 321.605468c1.933594 23.863282 22.183594 42.558594 46.109375 42.558594h204.863281c23.921875 0 44.175781-18.695312 46.105469-42.5625l26.007812-321.601562h6.542969c8.132812 0 15.824219-3.941407 20.578125-10.535157 4.753906-6.597656 6.058594-15.144531 3.484375-22.859375zm-249.320312-84.441406h83.0625v28.976562h-83.0625zm162.804687 437.019531c-.679687 8.402344-7.796875 14.980469-16.203125 14.980469h-204.863281c-8.40625 0-15.523438-6.578125-16.203125-14.980469l-25.816406-319.183593h288.898437zm-298.566406-349.183593 9.269531-27.789063c.210938-.640625.808594-1.070313 1.484375-1.070313h333.082031c.675782 0 1.269532.429688 1.484375 1.070313l9.269531 27.789063zm0 0"/><path d="m282.515625 465.957031c.265625.015625.527344.019531.792969.019531 7.925781 0 14.550781-6.210937 14.964844-14.21875l14.085937-270.398437c.429687-8.273437-5.929687-15.332031-14.199219-15.761719-8.292968-.441406-15.328125 5.925782-15.761718 14.199219l-14.082032 270.398437c-.429687 8.273438 5.925782 15.332032 14.199219 15.761719zm0 0"/><path d="m120.566406 451.792969c.4375 7.996093 7.054688 14.183593 14.964844 14.183593.273438 0 .554688-.007812.832031-.023437 8.269531-.449219 14.609375-7.519531 14.160157-15.792969l-14.753907-270.398437c-.449219-8.273438-7.519531-14.613281-15.792969-14.160157-8.269531.449219-14.609374 7.519532-14.160156 15.792969zm0 0"/><path d="m209.253906 465.976562c8.285156 0 15-6.714843 15-15v-270.398437c0-8.285156-6.714844-15-15-15s-15 6.714844-15 15v270.398437c0 8.285157 6.714844 15 15 15zm0 0"/></svg> </td> </tr> {/foreach} {if $user->discount} <tr> <th class="image"></th> <th class="name">скидка</th> <th class="price"></th> <th class="amount"></th> <th class="price" style="text-align: right;"> {$user->discount} % </th> <th class="remove"></th> </tr> {/if} <tr> <th class="price" colspan="4" style="text-align: right; padding-right: 20px;"> Итого {$cart->total_price|convert} {$currency->sign} </th> </tr> </table> {* <div class="catalog"> <div class="catalog__sizer"></div> <div class="catalog__gutter"></div> <!-- Товар--> {foreach $cart->purchases as $purchase} <div class="catalog__item-wrapper"> <div class="catalog__item"> <!-- Фото товара --> {$image = $purchase->product->images|first} {if $image} <img src="{$image->filename|resize:400:400}" alt="{$product->name|escape}"/> {/if} <a href="products/{$purchase->product->url}" class="catalog__bg"></a> <!-- Фото товара (The End) --> <div class="catalog__description"> <div class="catalog__item-name"> <a href="products/{$purchase->product->url}">{$purchase->product->name|escape}</a><br> {$purchase->variant->name|escape} </div> <div class="catalog__options"> <div class="catalog__amount"> <span> {($purchase->variant->price)|convert} {$currency->sign} за шт. </span> <div class="field-select"> <select class="field-select__select" name="amounts[{$purchase->variant->id}]" onchange="document.cart.submit();"> {section name=amounts start=1 loop=$purchase->variant->stock+1 step=1} <option value="{$smarty.section.amounts.index}" {if $purchase->amount==$smarty.section.amounts.index}selected{/if}>{$smarty.section.amounts.index} {$settings->units}</option> {/section} </select> </div> </div> <div class="catalog__total"> Итого: {($purchase->variant->price*$purchase->amount)|convert} {$currency->sign} <a href="cart/remove/{$purchase->variant->id}" class="btn" type="submit" data-result-text="В избранном"> Удалить </a> </div> </div> </div> </div> </div> {/foreach} </div> *} {* Скидочный купон <div class="page__row"> <div class="page__col page__col--6"> <h3>Итого: {$cart->total_price|convert} {$currency->sign}</h3> {if $user->discount} <p>Ваша скидка: {$user->discount} %</p> {/if} {if $coupon_request} <fieldset class="form__fieldset"> <legend class="form__legend"></legend> <p>Введите промокод (если есть):</p> {if $cart->coupon_discount>0} <p>Ваша скидка по промокоду: −{$cart->coupon_discount|convert} {$currency->sign}</p> {/if} <label class="field-text {if $coupon_error == 'invalid'}field-text--error{/if}"> <span class="field-text__input-wrap"> <input class="field-text__input coupon_code" style="width:119px;" type="text" name="coupon_code" value="{$cart->coupon->code|escape}"> {if $coupon_error == 'invalid'} <span class="field-text__help-text">Промокод недействителен</span> {/if} {if $cart->coupon->min_order_price>0} <span class="field-text__help-text"> Код {$cart->coupon->code|escape} действителен для заказов от {$cart->coupon->min_order_price|convert} {$currency->sign}) </span> {/if} </span> </label> <input class="btn" type="button" name="apply_coupon" value="Применить купон" onclick="document.cart.submit();"> </fieldset> {literal} <script> $("input[name='coupon_code']").keypress(function(event){ if(event.keyCode == 13){ $("input[name='name']").attr('data-format', ''); $("input[name='email']").attr('data-format', ''); document.cart.submit(); } }); </script> {/literal} {/if} </div> </div> *} {* Связанные товары *} {* {if $related_products} <h2>Так же советуем посмотреть</h2> <!-- Список каталога товаров--> <ul class="tiny_products"> {foreach $related_products as $product} <!-- Товар--> <li class="product"> <!-- Фото товара --> {if $product->image} <div class="image"> <a href="products/{$product->url}"><img src="{$product->image->filename|resize:200:200}" alt="{$product->name|escape}"/></a> </div> {/if} <!-- Фото товара (The End) --> <!-- Название товара --> <h3><a data-product="{$product->id}" href="products/{$product->url}">{$product->name|escape}</a></h3> <!-- Название товара (The End) --> {if $product->variants|count > 0} <!-- Выбор варианта товара --> <table> {foreach $product->variants as $v} <tr class="variant"> <td> {if $v->name}<label class="variant_name" for="related_{$v->id}">{$v->name}</label>{/if} </td> <td> {if $v->compare_price > 0}<span class="compare_price">{$v->compare_price|convert}</span>{/if} <span class="price">{$v->price|convert} <span class="currency">{$currency->sign|escape}</span></span> </td> <td> <a href="cart?variant={$v->id}">в корзину</a> </td> </tr> {/foreach} </table> <!-- Выбор варианта товара (The End) --> {else} Нет в наличии {/if} </li> <!-- Товар (The End)--> {/foreach} </ul> {/if} *} {* <div class="page__row"> {if $deliveries} <div class="page__col page__col--6"> <div class="field-radio"> <div class="field-radio__title"><h3>Выберите способ доставки:</h3></div> {foreach $deliveries as $delivery} <div class="field-radio__input-wrap"> <label class="field-radio__name" style="cursor: pointer;"> <input type="radio" class="field-radio__input" name="delivery_id" value="{$delivery->id}" {if $delivery_id==$delivery->id}checked{elseif $delivery@first}checked{/if} id="deliveries_{$delivery->id}"> <span style="text-decoration: underline; margin-left: 10px" class="field-radio__name-text"> {$delivery->name} - {if $cart->total_price < $delivery->free_from && $delivery->price>0} {$delivery->price|convert} {$currency->sign} {elseif $cart->total_price >= $delivery->free_from} бесплатно {/if} </span> </label> </div> <p> {$delivery->description} </p> {/foreach} </div> </div> *} <div class="page__col page__col--centered"> <fieldset class="form__fieldset"> <legend class="form__legend">Заполните контактные данные</legend> <label class="field-text {if $error == 'empty_name'}field-text--error{/if}"> <span class="field-text__input-wrap"> <span class="field-text__name">Ваше имя</span> <input class="field-text__input" name="name" type="text" value="{$name|escape}" data-format=".+" data-notice="Введите имя"> {if $error == 'empty_name'} <span class="field-text__help-text">Введите имя</span> {/if} </span> </label> <label class="field-text {if $error == 'empty_email'}field-text--error{/if}"> <span class="field-text__input-wrap"> <span class="field-text__name">E-mail</span> <input class="field-text__input" name="email" type="text" value="{$email|escape}" data-format="email" data-notice="Введите email"> {if $error == 'empty_email'} <span class="field-text__help-text">Введите адрес электронной почты</span> {/if} </span> </label> <label class="field-text"> <span class="field-text__input-wrap"> <span class="field-text__name">Телефон</span> <input class="field-text__input" name="phone" type="text" value="{$phone|escape}"> </span> </label> {* <label class="field-text"> <span class="field-text__input-wrap"> <span class="field-text__name">Адрес доставки</span> <input class="field-text__input" name="address" type="text" value="{$address|escape}"> </span> </label> *} <label class="field-text"> <span class="field-text__name">Комментарий к заказу</span> <span class="field-text__input-wrap"> <textarea class="field-text__input" name="comment" id="order_comment">{$comment|escape}</textarea> </span> </label> <label class="field-text {if $error == 'captcha'}field-text--error{/if}"> <span class="field-text__name">Вы не робот?</span> <span class="field-text__input-wrap"> <div class="captcha"><img src="captcha/image.php?{math equation='rand(10,10000)'}" alt='captcha'/></div> <input class="field-text__input" class="input_captcha" id="comment_captcha" type="text" name="captcha_code" value="" data-format="\d\d\d\d" data-notice="Введите капчу"> {if $error == 'captcha'} <span class="field-text__help-text">Введите капчу</span> {/if} </span> </label> <button type="submit" name="checkout" class="btn">Оформить заказ</button> </fieldset> </div> </div> </form> {else} <p>Перейти в <a href="/catalog/yuvelirnye-izdeliya">каталог ювелирных изделий</a> </p> <p>Подготовиться к <a href="/catalog/Обручальные_Кольца_2">свадьбе или помолвке</a> </p> {/if} Quote Link to post Share on other sites
Solution chocolate_moles Posted September 18, 2020 Solution Report Share Posted September 18, 2020 (edited) Вставьте <input type="hidden" name="amounts[{$purchase->variant->id}]" value="1"> после <td class="name"> Edited September 18, 2020 by chocolate_moles Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.