Jump to content

Problème avec PS 1.7 en affichage list-view


Recommended Posts

Bonjour,

J'ai un thème qui propose de switcher entre affichage de la liste des produits par grille ou par liste.

Pas de soucis en mode standard grille. Mais quand je passe en mode list, le nom de mes produits est remplacé par "Undefined". Et si je repasse ensuite en grille, ça reste à "Undefined".

Dans mon fichier custom.js j'ai :

function display(view)
{
	if (view == 'grid')
	{
		$('#js-product-list .product_content').removeClass('list').addClass('grid row');
		$('.product_content .item-product').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-6 col-lg-4');
		$('.product_content .item-product').each(function(index, element) {
			var html = '';
			var id_product = $(this).children('article.js-product-miniature').attr('data-id-product');
			var id_product_attr = $(this).children('article.js-product-miniature').attr('data-id-product-attribute');
			html += '<article class="js-product-miniature item_in" data-id-product="'+ id_product +'" data-id-product-attribute="'+ id_product_attr +'" itemscope itemtype="http://schema.org/Product">';
			html += '<div class="img_block">' + $(element).find('.img_block').html() + '</div>';
			html += '<div class="product_desc">';
				html += '<div class="desc_info">';
					html += '<h4>'+ $(element).find('h4').html() + '</h4>';
					var hookReviews = $(element).find('.hook-reviews');
					if (hookReviews.length) {
						html += hookReviews.clone().wrap('<div>').parent().html();
					}
					var price = $(element).find('.product-price-and-shipping').html();       // check : catalog mode is enabled
					if (price != null) {
						html += '<div class="product-price-and-shipping">'+ price + '</div>';
					}
					html += '<div class="variant-links">'+ $(element).find('.variant-links').html() + '</div>';
					html += '<div itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</div>';
				html += '</div>';				
				html += '<ul class="add-to-links">'+ $(element).find('.add-to-links').html() + '</ul>';				
			html += '</div>';
			html += '</article>';
			$(element).html(html);
		});
		$('.display').find('li#grid').addClass('selected');
		$('.display').find('li#list').removeAttr('class');
		$.totalStorage('display', 'grid');
	}
	else
	{	
		$('#js-product-list .product_content').removeClass('grid').addClass('list row');
		$('.product_content .item-product').removeClass('col-xs-12 col-sm-6 col-md-6 col-lg-4').addClass('col-xs-12');
		$('.product_content .item-product').each(function(index, element) {
			var html = '';
			var id_product = $(this).children('article.js-product-miniature').attr('data-id-product');
			var id_product_attr = $(this).children('article.js-product-miniature').attr('data-id-product-attribute');
			html = '<article class="js-product-miniature item_in" data-id-product="'+ id_product +'" data-id-product-attribute="'+ id_product_attr +'" itemscope itemtype="http://schema.org/Product"><div class="row">';
			html += '<div class="img_block col-xs-4 col-sm-4 col-md-4 col-lg-3 ">' + $(element).find('.img_block').html() + '</div>';
			html += '<div class="product_desc col-xs-8 col-sm-8 col-md-8 col-lg-9 ">';			
			html += '<h4>'+ $(element).find('h4').html() + '</h4>';
			var hookReviews = $(element).find('.hook-reviews');
			if (hookReviews.length) {
				html += hookReviews.clone().wrap('<div>').parent().html();
			}
			var price = $(element).find('.product-price-and-shipping').html();       // check : catalog mode is enabled
			if (price != null) {
				html += '<div class="product-price-and-shipping">'+ price + '</div>';
			}
		
			html += '<div itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</div>';
			html += '<ul class="add-to-links">'+ $(element).find('.add-to-links').html() + '</ul>';
			html += '<div class="variant-links">'+ $(element).find('.variant-links').html() + '</div>';
			html += '</div></article>';
			$(element).html(html);
		});
		$('.display').find('li#list').addClass('selected');
		$('.display').find('li#grid').removeAttr('class');
		$.totalStorage('display', 'list');
	}
}

Quelqu'un aurait une idée pour m'aider ?

 

Merci beaucoup :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...