Skip to content

Instantly share code, notes, and snippets.

@grippado
Created September 21, 2016 21:45
Show Gist options
  • Select an option

  • Save grippado/cd5476ab031ba6484fc6ba0e2bc44c14 to your computer and use it in GitHub Desktop.

Select an option

Save grippado/cd5476ab031ba6484fc6ba0e2bc44c14 to your computer and use it in GitHub Desktop.
ksdjjvb
var i;
for (i = 0; i < data.products.length; i++) {
var getProducts = data.products[i];
jQuery('.col-main .list-products.ajax-return').append(
'<li class="'+($('.toolbar .pager .view-mode .view_type.grid').hasClass('actived') ? 'col3' : 'col12')+' item">'
+'<a href="'+getProducts.url+'" title="'+getProducts.name+'">'
+'<figure>'
+'<span class="content_img">'
+'<img class="lazyload" data-original="' + getProducts.image + '140" src="' + getProducts.image + '140" alt="'+getProducts.name+'" />'
+(getProducts.price_block.price.discount_percent > 0 ? '<span class="tagSale lazyAtivado">-' + getProducts.price_block.price.discount_percent + '%</span>' : '')
+'</span>'
+'</figure>'
+'<section class="product-description">'
+'<div class="centered">'
+'<div class="infos">'
+'<h3 class="product-name">'+getProducts.name+'</h3>'
+'<p class="sub-title">'
+'<span class="autor-list"></span>'
+'</p>'
+'<section class="rating-value">'
+'<div class="ratings">'
+'<div class="rating-box rating-box-desabled"></div>'
+'</div>'
+'</section>'
+'<p>&nbsp;</p>'
+'<p class="text-description">'+getProducts.name+'</p>'
+'</div>'
+'<div class="block-price">'
+(getProducts.status == "inStock" || getProducts.status == "alert_me" ?
(getProducts.type_id != 'giftcard' ?
(getProducts.price_block.price.has_special_price == 0 ?
'<div class="list_price_group">'
+(getProducts.presale == true ? '<span class="preorder">pré-venda</span>' : "")
+'<span class="price">R$ '+ getProducts.price_block.price.final +'</span>'
+(getProducts.price_block.price.qty_installments_without_fee > 1 ?
'<span class="installments">'
+'<span class="installment_price">até '+getProducts.price_block.price.qty_installments_without_fee+'x sem juros de R$'+getProducts.price_block.price.value_installments_without_fee+'</span>'
+'</span>'
:
''
)
+'</div>'
:
'<div class="list_price_group">'
+(getProducts.presale == true ? '<span class="preorder">pré-venda</span>' : "")
+'<span class="old_price">R$ '+ getProducts.price_block.price.nominal +'</span>'
+'<span class="special_price">R$ '+ getProducts.price_block.price.final +'</span>'
+(getProducts.price_block.price.qty_installments_without_fee > 1 ?
'<span class="installments">'
+'<span class="installment_price">até '+getProducts.price_block.price.qty_installments_without_fee+'x sem juros de R$'+getProducts.price_block.price.value_installments_without_fee+'</span>'
+'</span>'
:
''
)
+'</div>'
)
:
''
)
:
'<div class="list_price_group">'
+'<div class="list_price_group produto-esgotado">Produto esgotado</div>'
+'</div>'
)
+'</div>'
+'</div>'
+'</section>'
+'</a>'
+'<section class="actions">'
+'<a href="#" class="quick-view-link" onclick="chaordic.push(["viewProduct", {"id":'+getProducts.sku+'}]);" data-url="http://local.saraiva.com.br/catalog/ajax_product/view/id/'+getProducts.id+'/">'
+'<span><?php echo $this->__('Quick View') ?></span>'
+'</a>'
+(getProducts.status == "inStock" ?
'<button type="button" title="<?php echo $this->__("Add") ?>" class="add-cart" onclick=""><span><?php echo $this->__('Add') ?></span></button>'
:
(getProducts.status == "out_of_line" || getProducts.status == "substituted" ?
'<a href="'+getProducts.url+'" class="btn-esgotado">Esgotado</a>'
:
'<a href="'+getProducts.url+'" class="btn-avise-me">Avise-me quando chegar</a>'
)
)
+'</section>'
+'</li>');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment