Jump to content

matik4

Members
  • Posts

    40
  • Joined

  • Last visited

  • Days Won

    1

matik4 last won the day on August 22 2022

matik4 had the most liked content!

Profile Information

  • Location
    Ireland
  • Activity
    User/Merchant

Recent Profile Visitors

4,138,047 profile views

matik4's Achievements

  1. Hi all, I know this version is quite old now, but sharing a fix I had to implement on a PrestaShop 1.7.6.7 site with multi-currency enabled. Posting here because I couldn’t find a clear solution for this specific case anywhere. The issue: When an order was placed in a non-default currency (e.g. shop base in EUR, customer pays in CHF), the order itself showed the correct totals in the order currency. But in ps_order_detail, the product line prices (product_price, original_product_price, unit/totals) were stored in the shop’s base currency. This meant inconsistencies: order summary looked fine, but the order details showed the wrong currency values (in BO and order confirmation emails). To resolve, you need to override OrderDetail class. Drop this into /override/classes/order/OrderDetail.php and clear cache: <?php class OrderDetail extends OrderDetailCore { /** * Set detailed product price to the order detail. * * @param Order $order * @param Cart $cart * @param array $product */ protected function setDetailProductPrice(Order $order, Cart $cart, $product) { $currency = new Currency((int) $order->id_currency); $this->setContext((int) $product['id_shop']); $id_tax_address = (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $nullVar = null; $price_tax_incl = Product::getPriceStatic( (int) $product['id_product'], true, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, $id_tax_address, $nullVar, true, true, $this->context ); $price_tax_excl = Product::getPriceStatic( (int) $product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, $id_tax_address, $nullVar, true, true, $this->context ); $price_tax_incl = Tools::ps_round($price_tax_incl, 6); $price_tax_excl = Tools::ps_round($price_tax_excl, 6); $converted_excl = Tools::convertPrice($price_tax_excl, $currency); if ($converted_excl === false || $converted_excl === null) { $converted_excl = 0.0; } $this->original_product_price = (float) Tools::ps_round($converted_excl, 6); $this->product_price = $this->original_product_price; $this->unit_price_tax_excl = (float) Tools::ps_round(Tools::convertPrice((float) $product['price'], $currency), 6); $this->unit_price_tax_incl = (float) Tools::ps_round(Tools::convertPrice((float) $product['price_wt'], $currency), 6); $this->total_price_tax_excl = (float) Tools::ps_round(Tools::convertPrice((float) $product['total'], $currency), 6); $this->total_price_tax_incl = (float) Tools::ps_round(Tools::convertPrice((float) $product['total_wt'], $currency), 6); $this->purchase_supplier_price = (float) $product['wholesale_price']; if ($product['id_supplier'] > 0 && ($supplier_price = ProductSupplier::getProductPrice( (int) $product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true )) > 0 ) { $this->purchase_supplier_price = (float) $supplier_price; } $this->setSpecificPrice($order, $product); $this->group_reduction = (float) Group::getReduction((int) $order->id_customer); $shop_id = $this->context->shop->id; $quantity_discount = SpecificPrice::getQuantityDiscount( (int) $product['id_product'], $shop_id, (int) $cart->id_currency, (int) $this->vat_address->id_country, (int) $this->customer->id_default_group, (int) $product['cart_quantity'], false, null, null, $nullVar, true, true, $this->context ); $unit_price = Product::getPriceStatic( (int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, 1, false, (int) $order->id_customer, null, $id_tax_address, $nullVar, true, true, $this->context ); $unit_price = Tools::ps_round($unit_price, 6); $this->product_quantity_discount = 0.00; if ($quantity_discount) { $this->product_quantity_discount = $unit_price; if (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC) { $this->product_quantity_discount = Tools::ps_round($unit_price, 6); } if (isset($this->tax_calculator)) { $this->product_quantity_discount -= $this->tax_calculator->addTaxes($quantity_discount['price']); $this->product_quantity_discount = Tools::ps_round($this->product_quantity_discount, 6); } } $this->discount_quantity_applied = ( ($this->specificPrice && $this->specificPrice['from_quantity'] > 1) ? 1 : 0 ); } } ✌️
  2. Just putting it here in case someone needs it - make sure to check ps_order_payment too (along with ps_cart and ps_orders) (make sure that your currency id is valid and does not = 0)
  3. In case someone is still looking for a solution. I used the following module: https://www.idnovate.com/en/1443-146-same-price-products-and-shipping-after-vat-applied.html#/support-3_months
  4. Hi! Perhaps someone will be able to help or suggest some direction in solving the following issue. PrestaShop sends e-mails to customers in wrong language when creating the order via back office. For example - customer is registered with with id_lang for English, but e-mail is sent in Spanish, which is the default language. Screen attached below. The order and customer were created via back office. Presta v. 1.7.6.9 All e-mail templates & languages are present both in /mails and /themes/x/mails/ I edited ps_customer, ps_order and ps_cart id_lang to english as well (no effect) When creating the order in BO my profile language was actually English, not Spanish
  5. @knacky @MerseyRay Just wanted to say thank you to both of you 🙏 based on your code I was able to make a module that allows editing customer's registered language.
  6. Dla innych szukajacych - dziala rowniez w PrestaShop 1.7.6.7 👌 Wielkie dzieki!
  7. Hi guys, For Prestashop 1.7.7.0-1.7.7.4 you need to modify a different file since the order page was migrated to Symfony: [please note that you will lose this modification if you upgrade Prestashop in future] File path: /src/Adapter/Order/CommandHandler/UpdateOrderShippingDetailsHandler.php You need to comment out the following part - in my case line 111 to 124: Before: //send mail only if tracking number is different AND not empty if (!empty($trackingNumber) && $oldTrackingNumber != $trackingNumber) { if (!$orderCarrier->sendInTransitEmail($order)) { throw new TransistEmailSendingException('An error occurred while sending an email to the customer.'); } $customer = new Customer((int) $order->id_customer); $carrier = new Carrier((int) $order->id_carrier, $order->id_lang); Hook::exec('actionAdminOrdersTrackingNumberUpdate', [ 'order' => $order, 'customer' => $customer, 'carrier' => $carrier, ], null, false, true, false, $order->id_shop); } After: //send mail only if tracking number is different AND not empty // if (!empty($trackingNumber) && $oldTrackingNumber != $trackingNumber) { // if (!$orderCarrier->sendInTransitEmail($order)) { // throw new TransistEmailSendingException('An error occurred while sending an email to the customer.'); // } // $customer = new Customer((int) $order->id_customer); // $carrier = new Carrier((int) $order->id_carrier, $order->id_lang); // Hook::exec('actionAdminOrdersTrackingNumberUpdate', [ // 'order' => $order, // 'customer' => $customer, // 'carrier' => $carrier, // ], null, false, true, false, $order->id_shop); // }
  8. Hi all! I wonder if you could help me. I'm trying to add a bit of JS code so that on product page, the product image is replaced with smaller size on mobile devices. I got it working on all product images except for the active image (cover) and the next one. From what I'm guessing, I think jquery is overriding my code, but I can't figure out a way to stop that from happening. If I add my code in the browser console it works perfectly with all images, but when I include the code in custom.js or theme.js (or via theme configuration - it has a custom js section) it doesn't work. I'm using Warehouse 4.4.2 template on Prestashop 1.7. My code is: const metaTagValue = document.querySelector('meta[property="og:type"'); const imageToReplace = document.querySelectorAll('#product-images-large .product-lmage-large img'); const thumbClick = document.querySelectorAll('img.thumb.js-thumb.img-fluid.swiper-lazy.swiper-lazy-loaded'); if (metaTagValue.content === 'product') { function replaceImages() { if (imageToReplace.length !== 0 && window.innerWidth <= 767) { for (const replacedImg of imageToReplace) { let x = `${replacedImg.dataset.src}`; let y = `${replacedImg.src}`; if (x.includes('large_default')) { replacedImg.src = `${x.replace('large_default', 'home_default')}`; replacedImg.width = '360'; replacedImg.height = '360'; } else if (y.includes('large_default')) { replacedImg.src = `${y.replace('large_default', 'home_default')}`; replacedImg.width = '360'; replacedImg.height = '360'; } } } } replaceImages(); for (eachThumb of thumbClick) { eachThumb.addEventListener('click', () => { replaceImages(); }) } } The website is www.cbdstore.ie but I'm trying it on test environment with template v 4.4.2, while the production site is 4.4.1. Any tips would be much appreciated!
  9. I tried different combinations with no success. I even changed the product.tpl instead from: <div class="row"> <div class="col-xs-12 {if $postheme.product_thumbnail == 0}col-md-5 {else} col-md-6 {/if}"> {block name='page_content_container'} <section class="page-content" id="content"> {block name='page_content'} {block name='product_cover_thumbnails'} {include file='catalog/_partials/product-cover-thumbnails.tpl'} {/block} {/block} </section> {/block} </div> to <div class="row"> <div class="col-xs-12 {if $postheme.product_thumbnail == 0}col-md-5 {else} col-md-6 {/if}"> {block name='page_content_container'} {foreach from=$product.images item=image} {if empty($product.cover)} <div style="width:100%;height:auto;"><img src="/img/p/pl.jpg" style="width:100%;" /></div> {else} <section class="page-content" id="content"> {block name='page_content'} {block name='product_cover_thumbnails'} {include file='catalog/_partials/product-cover-thumbnails.tpl'} {/block} {/block} </section> {/if} {/foreach} {/block} </div> and that still returns empty div
  10. Hi! I wonder if anyone can help me with this. I have a problem with 'no image' image not being displayed on the product page. On product list it works perfect. I tried to change the tpl in many different ways with 'if empty', 'if image > 0' etc with no effect. I changed the no image variable to direct link and still no effect whatsoever. Patient: https://elektronova.pl/akcesoria/16616-uklad-zaplonowy-mhs-35-230-spectrum--5907418719096.html Presta 1.7.5.2 My product-cover-thumbnail.tpl: <div class="images-container left_vertical"> {block name='product_images'} <ul class="product-images slider-nav"> {foreach from=$product.images item=image} <div class="thumb-container"> <div> <img class="thumb js-thumb {if $image.id_image == $product.cover.id_image} selected {/if}" src="{$image.bySize.home_default.url}" alt="{$image.legend}" title="{$image.legend}" itemprop="image" > </div> </div> {/foreach} </ul> {/block} {block name='product_cover'} <div class="product-view_content"> {block name='product_flags'} <ul class="product-flag"> {foreach from=$product.flags item=flag} <li class=" {$flag.type}">{$flag.label}</li> {/foreach} </ul> {/block} <div class="product-cover slider-for"> {foreach from=$product.images item=image} <div class="thumb-item"> {if $product.cover} <div class="easyzoom easyzoom--overlay"> <a href="{$image.bySize.large_default.url}"> <img class="" style="width:100%;" src="{$image.bySize.large_default.url}" alt="{$image.legend}" title="{$image.legend}" itemprop="image"> </a> </div> {else} <img src="{$urls.no_picture_image.bySize.large_default.url}" style="width:100%;"> {/if} </div> {/foreach} </div> </div> {/block} </div> {hook h='displayAfterProductThumbs'} <script type="text/javascript"> $(document).ready(function() { $('.images-container .slider-for').slick({ slidesToShow: 1, slidesToScroll: 1, focusOnSelect: true, arrows: true, fade: true, infinite: true, lazyLoad: 'ondemand', asNavFor: '.slider-nav' }); if ({$postheme.product_thumbnail} == 0) { $('.images-container .slider-nav').slick({ slidesToShow: 4, slidesToScroll: 1, asNavFor: '.slider-for', dots: false, arrows: true, infinite: true, focusOnSelect: true }); }else { $('.images-container .slider-nav').slick({ slidesToShow: 4, slidesToScroll: 1, asNavFor: '.slider-for', vertical:true, dots: false, arrows: true, infinite: true, focusOnSelect: true, responsive: [ { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 1, } }, { breakpoint: 767, settings: { slidesToShow: 4, slidesToScroll: 1, } }, { breakpoint: 543, settings: { slidesToShow: 3, slidesToScroll: 1, } }, { breakpoint: 399, settings: { slidesToShow: 2, slidesToScroll: 1, } } ] }); } $('.images-container .slider-for').slickLightbox({ src: 'src', itemSelector: '.thumb-item img' }); if($(window).width() >= 992) { var $easyzoom = $('.images-container .easyzoom').easyZoom(); } $(window).resize(function(){ if($(window).width() >= 992) { var $easyzoom = $('.images-container .easyzoom').easyZoom(); $('.easyzoom--overlay').addClass('easyzoom'); } else { $('.easyzoom--overlay').removeClass('easyzoom'); } }); }); </script>
  11. Solved courtesy of @atomek , the solution is as below: {nl2br($field.text) nofilter}
  12. Powyzsza formula rozwiazala problem, happy days! Dzieki wielkie!
  13. Witam, Potrzebuje pomocy z ponizszym problemem. Probuje edytowac szablon realizacji zamowienia w Prescie 1.7.5.1 w taki sposob, aby tekst personalizacji produktu zachowal formatowanie tzn. odstepy miedzy wierszami - line breaks. Obecnie jezeli tekst zapisany jest tak jak w ponizszy sposob: line 1 blabla line 2 blablab line 3 blablaba Prestashop w koszyku czy w realizacji zamowienia wyswietli to jako: line 1 blabla line 2 blablab line 3 blablaba Na poziomie back office problem rozwiazalem w ponizszy sposob: {$data['value']|replace:' ':'<br />'} Niestety podobny kod nie dziala na FO i powoduje wysypanie sie strony (zamiast $data uzylem $field.text) Udalo mi sie czesciowo rozwiazac problem poprzez: {nl2br($field.text)} Niestety to powoduje, ze dodane jest <br /> jako tekst, a nie jako czesc kodu html tak jak ponizej: line 1 blabla<br /> line 2 blablab<br /> line 3 blablaba Plik w ktorym probuje dokonac zmian to cart-detailed-product-line.tpl: <div> {foreach from=$customization.fields item="field"} <div class="product-customization-line row"> <div class="col-sm-6 col-xs-6 perso-koszyk"> {$field.label} </div> <div class="col-sm-6 col-xs-6 perso-koszyk"> {if $field.type == 'text'} {if (int)$field.id_module} {$field.text nofilter} {else} {nl2br($field.text)} {/if} {elseif $field.type == 'image'} <img src="{$field.image.small.url}"> {/if} </div> </div> {/foreach} </div> Bylbym niezmiernie wdzieczny za jakiekolwiek wskazowki. Pozdrawiam, Mateusz
  14. Hello, I wonder if anyone can help me with this. I'm trying to edit the shopping cart template in Presta 1.7.5.1 so that the product customization text is displayed with preserved line breaks. Currently if there are any line breaks Presta ignores them. For example customer's product customization text is: line 1 blabla line 2 blablab line 3 blablaba Prestashop will display it in the summary as: line 1 blabla line 2 blablab line 3 blablaba I have it sorted in the back office by using: {$data['value']|replace:' ':'<br />'} I cannot get it working in the front office. The above code breaks the website (used with $field.text instead). I got it working partially by using: {nl2br($field.text)} However this results in <br /> tags shown as a text - rather than doing anything - as on the below example: line 1 blabla<br /> line 2 blablab<br /> line 3 blablaba The file I am trying to edit is located in cart-detailed-product-line.tpl and is as follows: <div> {foreach from=$customization.fields item="field"} <div class="product-customization-line row"> <div class="col-sm-6 col-xs-6 perso-koszyk"> {$field.label} </div> <div class="col-sm-6 col-xs-6 perso-koszyk"> {if $field.type == 'text'} {if (int)$field.id_module} {$field.text nofilter} {else} {nl2br($field.text)} {/if} {elseif $field.type == 'image'} <img src="{$field.image.small.url}"> {/if} </div> </div> {/foreach} </div> I would really appreciate any help on this! Kind Regards, Mateusz
  15. Already solved - if anyone encounters similar issue: for me it happened because I actually played with product-cover-thumbnails.tpl code to move the miniatures under the product cover and then I gave it few touches with CSS. The second I restored original file the issue disappeared, so I moved the miniatures using CSS only with 'order' property.
×
×
  • Create New...