robdk Posted January 27, 2014 Share Posted January 27, 2014 (edited) Witam Dokonałem przeróbki koszyka by odmieniać słowo produkt w zależności od ilości produktów. Oryginalnie są tylko dwie odmiany : produkt, produkty. Ja dodałem jeszcze "produktów" jeśli jest ich więcej niż 4. Zmiany dokonałem w koszyku widocznym na górze strony jak i w realizacji zamówienia. Koszyk: edycja pliku blockuserinfo.tpl Było <span class="ajax_cart_product_txt{if $cart_qties != 1} hidden{/if}">{l s='Product' mod='blockuserinfo'}</span> <span class="ajax_cart_product_txt_s{if $cart_qties < 2} hidden{/if}">{l s='Products' mod='blockuserinfo'}</span> Zmieniłem na: <span class="ajax_cart_product_txt{if $cart_qties > 1 || $cart_qties ==0} hidden{/if}">{l s='Product' mod='blockuserinfo'}</span> <span class="ajax_cart_product_txt_s{if $cart_qties ==1 || $cart_qties >4 || $cart_qties ==0} hidden{/if}">{l s='Products' mod='blockuserinfo'}</span> <span class="ajax_cart_product_txt_t{if $cart_qties < 5} hidden{/if}">{l s='produktów' mod='blockuserinfo'}</span> Uwaga - przeróbka tylko dla sklepu w języku polskim, jeśli są inne języki trzeba przetłumaczyć słowo "produktów" w tłumaczeniach w pliku: if (parseInt(jsonData.nbTotalProducts) > 0) { $('.ajax_cart_no_product').hide(); $('.ajax_cart_quantity').text(jsonData.nbTotalProducts); $('.ajax_cart_quantity').fadeIn('slow'); $('.ajax_cart_total').fadeIn('slow'); if (parseInt(jsonData.nbTotalProducts) > 1) { $('.ajax_cart_product_txt').each( function () { $(this).hide(); }); $('.ajax_cart_product_txt_s').each( function () { $(this).show(); }); } else { $('.ajax_cart_product_txt').each( function () { $(this).show(); }); $('.ajax_cart_product_txt_s').each( function () { $(this).hide(); }); } } else { $('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt, .ajax_cart_total').each(function(){ $(this).hide(); }); $('.ajax_cart_no_product').show('slow'); } zmieniłem na: if (parseInt(jsonData.nbTotalProducts) > 0) { $('.ajax_cart_no_product').hide(); $('.ajax_cart_quantity').text(jsonData.nbTotalProducts); $('.ajax_cart_quantity').fadeIn('slow'); $('.ajax_cart_total').fadeIn('slow'); if (parseInt(jsonData.nbTotalProducts) < 5 && parseInt(jsonData.nbTotalProducts) > 1) { $('.ajax_cart_product_txt').each( function () { $(this).hide(); }); $('.ajax_cart_product_txt_s').each( function () { $(this).show(); }); $('.ajax_cart_product_txt_t').each( function () { $(this).hide(); }); } else if (parseInt(jsonData.nbTotalProducts) == 1) { $('.ajax_cart_product_txt').each( function () { $(this).show(); }); $('.ajax_cart_product_txt_s').each( function () { $(this).hide(); }); $('.ajax_cart_product_txt_t').each( function () { $(this).hide(); }); } else if (parseInt(jsonData.nbTotalProducts) > 4) { $('.ajax_cart_product_txt').each( function () { $(this).hide(); }); $('.ajax_cart_product_txt_s').each( function () { $(this).hide(); }); $('.ajax_cart_product_txt_t').each( function () { $(this).show(); }); } } else { $('.ajax_cart_quantity, .ajax_cart_product_txt_s, .ajax_cart_product_txt_t, .ajax_cart_product_txt, .ajax_cart_total').each(function(){ $(this).hide(); }); $('.ajax_cart_no_product').show('slow'); } Teraz dla zamówienia: plik shopping-cart.tpl // <![CDATA[ var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}'; var currencyRate = '{$currencyRate|floatval}'; var currencyFormat = '{$currencyFormat|intval}'; var currencyBlank = '{$currencyBlank|intval}'; var txtProduct = "{l s='product' js=1}"; var txtProducts = "{l s='products' js=1}"; var deliveryAddress = {$cart->id_address_delivery|intval}; // ]]> na: // <![CDATA[ var currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}'; var currencyRate = '{$currencyRate|floatval}'; var currencyFormat = '{$currencyFormat|intval}'; var currencyBlank = '{$currencyBlank|intval}'; var txtProduct = "{l s='product' js=1}"; var txtProducts = "{l s='products' js=1}"; var txtProducts2 = "{l s='produktów' js=1}"; var deliveryAddress = {$cart->id_address_delivery|intval}; // ]]> oraz <p>{l s='Your shopping cart contains:'} <span id="summary_products_quantity">{$productNumber} {if $productNumber == 1}{l s='product'}{else}{l s='products'}{/if}</span></p> na: <p>{l s='Your shopping cart contains:'} <span id="summary_products_quantity">{$productNumber} {if $productNumber == 1}{l s='product'}{else if $productNumber > 4} {l s='produktów'}{else if $productNumber >1 || $productNumber < 5}{l s='products'}{/if}</span></p> i w pliku: cart-summary.js $('#summary_products_quantity').html(nbrProducts + ' ' + (nbrProducts > 1 ? txtProducts : txtProduct)); na if (nbrProducts == 1) { $('#summary_products_quantity').html(nbrProducts + ' ' + (txtProduct)); } else if (nbrProducts <= 4 && nbrProducts > 1) { $('#summary_products_quantity').html(nbrProducts + ' ' + (txtProducts)); } else if (nbrProducts > 4) { $('#summary_products_quantity').html(nbrProducts + ' ' + (txtProducts2)); } Edited January 27, 2014 by robdk (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts