Commit a174e96c authored by Nahla Shiri's avatar Nahla Shiri

correction bugs Redmine

parent d5d33962
......@@ -1149,6 +1149,8 @@ aside.news-wrapper {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
cursor:pointer;
}
#slides .element-slider:last-child .image{
margin-bottom: 0px;
......@@ -1487,14 +1489,14 @@ label.chevron.bottom::first-letter {
padding-top: 156px;
padding-bottom: 30px;
}
.product-info .info-content h3,
.product-info .info-content h1,
.product-info .info-content h2{
font-size: 20px;
line-height: 24px;
letter-spacing: 1px;
text-transform: uppercase;
}
.product-info .info-content h3{
.product-info .info-content h1{
padding-bottom: 5px;
}
.product-info .btn-list{
......@@ -1628,9 +1630,9 @@ label.chevron.bottom::first-letter {
.easyzoom.is-error img {
cursor: not-allowed;
}
.easyzoom-notice {
/*.easyzoom-notice {
display: none;
}
}*/
.easyzoom-flyout {
position:absolute;
......
......@@ -603,7 +603,13 @@ function onScroll(event){
var currLink = $(this);
var refElement = $(currLink.attr("href"));
//console.log(currLink);
if (refElement.length && refElement.position().top - ( $(".main").outerHeight() / 2 - titleHeight - $(".footer").outerHeight() ) <= scrollPos && refElement.position().top + refElement.height() > scrollPos) {
var windowWidth = $(window).width();
var margin_top = 0;
if(windowWidth > 1920)
margin_top = 150;
else
margin_top = 50;
if (refElement.length && refElement.position().top - ( $(".main").outerHeight() / 2 - titleHeight - $(".footer").outerHeight()- margin_top ) <= scrollPos && refElement.position().top + refElement.height() > scrollPos) {
$('.subcat a').removeClass("active");
currLink.addClass("active");
......
......@@ -12,7 +12,6 @@ jQuery(document).ready(function() {
var download_link = jQuery('.download_file_link').attr('href');
var current_var = jQuery('.download_file_link').attr('id');
var variation_id = jQuery('input[name="variation_id"]').val();
// alert(variation_id);
if (variation_id == 0)
id = current_var;
else
......@@ -55,12 +54,14 @@ jQuery(document).ready(function() {
jQuery("#pa_univers .selected").each(function() {
tabunivers[i++] = jQuery(this).text();
});
var sku = jQuery("#sku-search").val();
var selected_colors = tabcolor.join(',');
var selected_formats = tabformat.join(',');
var selected_matiere = tabmatiere.join(',');
var selected_univers = tabunivers.join(',');
var params = {pa_couleur: selected_colors, pa_format: selected_formats, pa_matiere: selected_matiere, pa_univers: selected_univers};
var params = {pa_couleur: selected_colors, pa_format: selected_formats, pa_matiere: selected_matiere, pa_univers: selected_univers,sku:sku};
window.location.href = "?" + jQuery.param(params);
jQuery('.list-animation section').each(function() {
......@@ -99,8 +100,11 @@ jQuery(document).ready(function() {
}
});
if(result_found == false)
jQuery('.search_notfound').text(' Aucun produit ne correspond à votre recherche');
{jQuery('.search_notfound').text(' Aucun produit ne correspond à votre recherche');
console.log(result_found);
}
});
......
......@@ -10,6 +10,9 @@ function loadProductContent() {
$('.product-details .list').width('100%');
$('.product-details form').width('21.7%');
}
$('.pa_couleur li').getListColors();
$('.pa_couleur li').selectColor();
$('.pa_format li').selectFormat();
......@@ -18,50 +21,49 @@ function loadProductContent() {
$('.pa_paquets li').selectFormat();
$('.pa_designation li').selectFormat();
$('.list-wrapper .color-list').setColorToWhite('input');
$('#zoom').zoom();
$('#zoom, .element-slider').zoom();
$('article[data-color], .pa_couleur li').click(function(e) {
$(this).selectSlide($('#slides'));
});
$('#mozaique').open_gallery();
initFunction();
$.fn.responsive();
$('.variations_form').on('reset_data', function()
{
{
console.log("reset data");
$attributes = $('.variations .list');
var num_attr = $('.variations .list').length;
// alert(num_attr);
$attributes.each(function(i)
{
var $attr = $(this);
if (!$attr.hasClass('pa_couleur') && !$attr.hasClass('pa_taille'))
{
//alert($attr.hasClass('first_attr'));
if (!$attr.hasClass("first_attr") || num_attr == 1)
{
console.log(i, $attr, $attr.find('input:not(:disabled):checked').length);
if (!$attr.find('input:not(:disabled):checked').length)
{
{
$firstInput = $attr.find('input:not(:disabled)').first();
$firstInput.prop('checked',true);
$firstInput.change();
}
}
/*if ($attr.hasClass('pa_taille'))
{
console.log('--------' + i, $attr, $attr.find('input:not(:disabled):checked').length);
if (!$attr.find('input:not(:disabled):checked').length)
{ console.log('heeeere');
$firstInput = $attr.find('input:not(:disabled)').first();
$firstInput.prop('checked',true);
$firstInput.change();
}
}*/
else
{
$('.list').first().find('input:disabled').prop('disabled',false);
// jQuery(jQuery('.list').first()).find('input').first().prop('checked',true);
//jQuery(jQuery('.list').first()).find('input').first().change();
}
});
});
function onFoundVariation()
{
console.log('found variation');
$('.list').first().find('input:disabled').prop('disabled',false);
//$('.variations_form .format_list input').prop('checked',false);
$('.variations_form .color-list input:disabled').prop('disabled',false);
$('.variations_form .attribute_pa_taille input:disabled').prop('disabled',false);
console.log('found', $('.variations_form .format-list input:checked + * + .format-desc'));
//var format = $('.variations_form .format-list input:checked + * + .format-desc').text();
var format='';
......@@ -74,6 +76,23 @@ function loadProductContent() {
$('.info-color').text($('.color-list input:checked').attr('value'));
var varID = jQuery('input[name="variation_id"]').val();
/**********NS***********/
var variations_has_file = $('.download_file').data('fiche');
var tab_var_file = variations_has_file.split(',').slice(0, -1);
//console.log(tab_var_file);
if ($.inArray(varID, tab_var_file) > -1)
{
$('.download_file').show();
}
else
{
$('.download_file').hide();
}
/**********************/
if (varID != 0) {
var price = jQuery('.woocommerce-variation-price .woocommerce-Price-amount').text();
......@@ -111,13 +130,14 @@ function loadProductContent() {
$(function(){
var initFunction=function(){
$('a[href^="#"], .easyzoom img').click(function(e){
e.preventDefault();
//e.preventDefault();
});
};//END init Function
$.fn.zoom = function(){ //Zoom on Image
$(this).on('click', function() {
//$('.loading-hd').show();
var zoom = $(this);
$( ".easyzoom" ).each(function( i ) {
//$( ".easyzoom" ).each(function( i ) {
var $easyzoom = $(this).easyZoom();
var api = $easyzoom.filter('.easyzoom--with-toggle').data('easyZoom');
api.teardown();
......@@ -127,11 +147,17 @@ $(function(){
zoom.removeClass("active");
api.teardown();
} else {
$this.data("active", true);
zoom.addClass("active");
zoom.removeClass('is-loading');
zoom.addClass("is-ready");
api._init();
$(this).trigger( "mouseenter" );
//api.teardown();
}
});
//});
});
} //END Zoom On Image
$.fn.getListColors = function(){
......@@ -149,6 +175,9 @@ $(function(){
formatWrapper.css({'height' : formatH , 'width' : formatW });
})
}
$.fn.selectColor= function(){
$(this).on('click',function(){
var $input = $(this).find('input');
......@@ -328,6 +357,9 @@ $(function(){
//localStorage['from-site'] = true;
$('head').append($('.header-shop'));
var toLink = $(this).data('link');
$(document).attr("title", $(this).data('title'));
// $(document).attr("description", $(this).data('description'));
// $.post(toLink, { fromSite: true});
//$.cookie("formSite", 1);
$('.load-page').parent().addClass('active');
......
......@@ -135,14 +135,14 @@
* @param {Event} e
*/
EasyZoom.prototype._onEnter = function(e) {
var touches = e.originalEvent.touches;
// var touches = e.originalEvent.touches;
this.isMouseOver = true;
if (!touches || touches.length == 1) {
// if (!touches || touches.length == 1) {
e.preventDefault();
this.show(e, true);
}
// }
};
/**
......
......@@ -25,7 +25,7 @@ function nap_enqueue_scripts() {
// Enqueue jQuery UI and autocomplete
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-autocomplete');
wp_enqueue_script( 'wc-add-to-cart-variation' );
wp_enqueue_script('wc-add-to-cart-variation');
}
add_action('wp_enqueue_scripts', 'nap_enqueue_scripts');
......@@ -305,18 +305,22 @@ function nap_menu() {
if ($cat->category_parent == 0) {
$category_id = $cat->term_id;
$nappe_sets = false;
if($category_id == 19){ $nappe_sets = true;} else { $nappe_sets = false;}
if ($category_id == 19) {
$nappe_sets = true;
} else {
$nappe_sets = false;
}
$menu.= '<li class ="parent-cat" data-page = "' . $category_id . '" data-img = "' . nap_category_image($category_id) . '"><a href="' . get_term_link($cat->slug, 'product_cat') . '">' . $cat->name . '</a>';
$args2 = array(
'taxonomy' => $taxonomy,
'child_of' => 0,
'parent' => $category_id,
# JC 20170901
# JC 20170901
#'orderby' => 'title',
'orderby' => 'meta_value_num',
'meta_key' => 'order',
# JC end
# JC end
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
......@@ -333,15 +337,13 @@ function nap_menu() {
$calss = 'active';
else
$calss = '';
if($nappe_sets){
$sub_name = $sub_category->name;
}
else{
$sub_name = substr(strstr($sub_category->name," "), 1);
}
if ($nappe_sets) {
$sub_name = $sub_category->name;
} else {
$sub_name = substr(strstr($sub_category->name, " "), 1);
}
$menu.= '<li data-cover = "' . nap_category_image($sub_category->term_id) . '"><a class="' . $calss . '" href="#cat' . $sub_category->term_id . '">' . $sub_name . '</a></li>';
}
}
......@@ -354,27 +356,27 @@ function nap_menu() {
}
function nap_variation_url($variationID) {
/****** MS ******/
$product = wc_get_product( $variationID);
/* * **** MS ***** */
$product = wc_get_product($variationID);
$url = '?';
$product_attributes = ($product->get_attributes());
foreach ($product_attributes as $key => $p_attr) {
$url .= $key . '=' .$p_attr.'&';
$url .= $key . '=' . $p_attr . '&';
}
$url .='variation_id=' . $variationID;
return preg_replace('/\s+/', '', $url);
/****** END MS ******/
/* * **** END MS ***** */
/* OLD NS
$variable_product = wc_get_product($variationID);
$variable_product = wc_get_product($variationID);
$couleur = $variable_product->get_attribute('couleur');
$color_url = get_term_by('slug', $couleur, 'pa_couleur');
//$format = $variable_product->get_attribute('format');
$format = get_post_meta($variationID, 'attribute_pa_format', true);
$format_url = get_term_by('slug', $format, 'pa_format');
$url = '?attribute_couleur=' . $color_url->slug . '&attribute_format=' . $format_url->slug . '&variation_id=' . $variationID;
return preg_replace('/\s+/', '', $url);
END OLD NS */
$couleur = $variable_product->get_attribute('couleur');
$color_url = get_term_by('slug', $couleur, 'pa_couleur');
//$format = $variable_product->get_attribute('format');
$format = get_post_meta($variationID, 'attribute_pa_format', true);
$format_url = get_term_by('slug', $format, 'pa_format');
$url = '?attribute_couleur=' . $color_url->slug . '&attribute_format=' . $format_url->slug . '&variation_id=' . $variationID;
return preg_replace('/\s+/', '', $url);
END OLD NS */
}
function nap_variation_color($variationID) {
......@@ -424,12 +426,12 @@ function nap_distinct_color_variations($variations) {
}
function nap_variation_format($variationID) {
/*$variable_product = wc_get_product($variationID);
$name= $variable_product->get_attribute('format');*/
$meta = get_post_meta($variationID, 'attribute_pa_format', true);
$term = get_term_by('slug', $meta, 'pa_format');
return $slug = $term->slug;
/* $variable_product = wc_get_product($variationID);
$name= $variable_product->get_attribute('format'); */
$meta = get_post_meta($variationID, 'attribute_pa_format', true);
$term = get_term_by('slug', $meta, 'pa_format');
return $slug = $term->slug;
}
function nap_distinct_format_variations($variations) {
......@@ -448,38 +450,73 @@ function nap_distinct_format_variations($variations) {
}
function nap_filter_attribute($id, $args, $options, $list_attr, $search) {
if(isset($search['pa_format']) && $search['pa_format']!=''){
$list_format=explode(",", $search['pa_format']);
$intersect_format = array_intersect($list_attr['pa_format'],$list_format);
$ref_product = 0; $serach_by_ref=false;
if (isset($search['sku']) && $search['sku'] != '') {
$serach_by_ref=true;
$_product = wc_get_product($id);
if( $_product->is_type( 'simple' ) ){
$product_id = get_product_by_sku( $search['sku'] );
if($id == $product_id[0]->post_id)
$ref_product = 1;
} elseif( $_product->is_type( 'variable' ) ){
$variation = get_product_by_sku($search['sku']);
$variation_id = $variation[0]->post_id;
$variable_product = wc_get_product($variation_id);
if($id == $variable_product->parent_id)
$ref_product = 1;
}
// print $ref_product;
}
if(isset($search['pa_couleur']) && $search['pa_couleur']!=''){
$list_couleur=explode(",", $search['pa_couleur']);
if(isset($list_attr['pa_couleur']) && is_array($list_attr['pa_couleur']))
{$intersect_couleur = array_intersect($list_attr['pa_couleur'],$list_couleur);}
if (isset($search['pa_format']) && $search['pa_format'] != '') {
$list_format = explode(",", $search['pa_format']);
$intersect_format = array_intersect($list_attr['pa_format'], $list_format);
}
if(isset($search['pa_matiere']) && $search['pa_matiere']!=''){
$list_matiere=explode(",", $search['pa_matiere']);
if (isset($search['pa_couleur']) && $search['pa_couleur'] != '') {
$list_couleur = explode(",", $search['pa_couleur']);
if (isset($list_attr['pa_couleur']) && is_array($list_attr['pa_couleur'])) {
$intersect_couleur = array_intersect($list_attr['pa_couleur'], $list_couleur);
}
}
if (isset($search['pa_matiere']) && $search['pa_matiere'] != '') {
$list_matiere = explode(",", $search['pa_matiere']);
}
if(isset($search['pa_univers']) && $search['pa_univers']!=''){
$list_univers=explode(",", $search['pa_univers']);
if (isset($search['pa_univers']) && $search['pa_univers'] != '') {
$list_univers = explode(",", $search['pa_univers']);
}
if(
( ($list_couleur && !empty($intersect_couleur)) || empty($list_couleur) ) &&
( ($list_format && !empty($intersect_format)) || empty($list_format) ) &&
( ($list_univers && in_array($list_attr['pa_univers'],$list_univers)) || empty($list_univers) ) &&
( ($list_matiere && in_array($list_attr['pa_matiere'],$list_matiere)) || empty($list_matiere) )
)
{
echo nap_get_item($id, $args, 'catalogue', $options);
}
if( $serach_by_ref && $ref_product)
{ echo nap_get_item($id, $args, 'catalogue', $options);
return;
}
if ( (!$serach_by_ref)&&
( ($list_couleur && !empty($intersect_couleur)) || empty($list_couleur) ) &&
( ($list_format && !empty($intersect_format)) || empty($list_format) ) &&
( ($list_univers && in_array($list_attr['pa_univers'], $list_univers)) || empty($list_univers) ) &&
( ($list_matiere && in_array($list_attr['pa_matiere'], $list_matiere)) || empty($list_matiere) )
) {
echo nap_get_item($id, $args, 'catalogue', $options);
}
}
function nap_get_item($post_ID, $args = null, $current_page = '', $options = null, $search = null) {
$terms = get_the_terms($post_ID, 'product_cat');
$link = $image = $size = '';
if (isset($options)) {
if ($options['dwnldLink']) {
......@@ -501,29 +538,27 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
}
}
if($current_page == 'phototheque'){
$img = '';
if(has_post_thumbnail($post_ID))
{ $prod_image = get_the_post_thumbnail_url($post_ID, 'thumbnail');
$prod_hd = get_the_post_thumbnail_url($post_ID, 'full');
}
else {
$product = new WC_Product_Variable( $post_ID );
if ($current_page == 'phototheque') {
$img = '';
if (has_post_thumbnail($post_ID)) {
$prod_image = get_the_post_thumbnail_url($post_ID, 'thumbnail');
$prod_hd = get_the_post_thumbnail_url($post_ID, 'full');
} else {
$product = new WC_Product_Variable($post_ID);
$variations = $product->get_available_variations();
if(isset($variations[0]))
{ $prod_image = get_the_post_thumbnail_url($variations[0]['variation_id'], 'thumbnail');
if (isset($variations[0])) {
$prod_image = get_the_post_thumbnail_url($variations[0]['variation_id'], 'thumbnail');
$prod_hd = get_the_post_thumbnail_url($variations[0]['variation_id'], 'full');
}
}
$nap_img = ' <a class = "circle-btn download-btn hidden-elem" download href="' . $prod_hd . '"></a>';
$nap_img.= '<img class="transition" src="' . $prod_image . '" alt="'. get_the_title($post_ID).'" title="'. get_the_title($post_ID).'">';
}
else
{
$nap_img = $link;
$nap_img.= '<img class="transition" src="' . $image . '" alt="" title="">';
}
$nap_img.= '<img class="transition" src="' . $prod_image . '" alt="' . get_the_title($post_ID) . '" title="' . get_the_title($post_ID) . '">';
} else {
$nap_img = $link;
$nap_img.= '<img class="transition" src="' . $image . '" alt="' . $terms[1]->name . ' ' . get_the_title($post_ID) . '" data-title="' . $terms[1]->name . ' ' . get_the_title($post_ID) . '" data-description="' . strip_tags($terms[1]->description) . '">';
}
$nap_article = '<article class = " visible row ">
<a href="#"></a>
<figure data-bg = "" class = "' . $size . ' transition">
......@@ -534,18 +569,19 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
$variations = get_posts($args);
$temp_colors = array();
if (!empty($variations)) {
foreach ($variations as $key => $value) {
$color = nap_variation_color($value->ID);
$format = nap_variation_format($value->ID);
if (!in_array($color, $temp_colors)) {
$temp_colors[] = $color;
$nap_article.='<li data-link = "' . get_permalink($post_ID) . nap_variation_url($value->ID) . '" data-image = "' . get_the_post_thumbnail_url($value->ID, 'thumbnail') . '" data-color = "' . $color . '" data-format = "' . $format . '"></li> ';
$nap_article.='<li data-link = "' . get_permalink($post_ID) . nap_variation_url($value->ID) . '" data-image = "' . get_the_post_thumbnail_url($value->ID, 'thumbnail') . '" data-description="' . strip_tags($terms[1]->description) . '" data-title = "' . $terms[1]->name . ' ' . $title_item . '" data-color = "' . $color . '" data-format = "' . $format . '"><a href="' . get_permalink($post_ID) . nap_variation_url($value->ID) . '"></a></li> ';
}
}
} else {
$nap_article.='<li data-link = "' . get_permalink($post_ID) . '" data-image = "' . get_the_post_thumbnail_url($value->ID, 'thumbnail') . '" data-color = "' . get_post_thumbnail_id($post_ID) . '" data-format = ""></li> ';
$nap_article.='<li data-link = "' . get_permalink($post_ID) . '" data-image = "' . get_the_post_thumbnail_url($value->ID, 'thumbnail') . '" data-color = "' . get_post_thumbnail_id($post_ID) . '" data-format = ""><a href="' . get_permalink($post_ID) . '"></a></li> ';
}
$nap_article.='</ul>';
endif;
......@@ -666,6 +702,7 @@ function nap_save_general_proddata_custom_field($post_id) {
session_start();
$ref = false;
//MS 2017-08-02 : Get referrer
function externe_referrer() {
session_start();
......@@ -673,18 +710,15 @@ function externe_referrer() {
$postid = url_to_postid($url);
$notRefreshed = true;
$uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$pageWasRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) &&($_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0' || $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache');
$pageWasRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) && ($_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0' || $_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache');
//The second parameter on print_r returns the result to a variable rather than displaying it
$RequestSignature = md5($_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'].print_r($_POST, true));
if (($pageWasRefreshed || empty($url) )) // && (from-site) //$_SESSION['LastRequest'] == $RequestSignature
{
$ref = true;
}
else
{
$ref = false;
$_SESSION['LastRequest'] = $RequestSignature;
}
$RequestSignature = md5($_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING'] . print_r($_POST, true));
if (($pageWasRefreshed || empty($url))) { // && (from-site) //$_SESSION['LastRequest'] == $RequestSignature
$ref = true;
} else {
$ref = false;
$_SESSION['LastRequest'] = $RequestSignature;
}
return $ref;
}
......@@ -692,12 +726,12 @@ function get_logged_user() {
if (is_user_logged_in()) {
global $current_user;
get_currentuserinfo();
if($current_user->user_lastname || $current_user->user_firstname){
if ($current_user->user_lastname || $current_user->user_firstname) {
echo $current_user->user_lastname . ' ' . $current_user->user_firstname;
}else{
} else {
echo $current_user->user_login;
}
echo '<span class = "logout"><a href="' . wp_logout_url( home_url() ) . '">déconnexion</a></span>';
echo '<span class = "logout"><a href="' . wp_logout_url(home_url()) . '">déconnexion</a></span>';
} else {
echo '<a class="login" href="#">accès pro</a>';
}
......@@ -705,8 +739,9 @@ function get_logged_user() {
//remove margin top margin header Wordpress
add_action('get_header', 'my_filter_head');
function my_filter_head() {
remove_action('wp_head', '_admin_bar_bump_cb');
remove_action('wp_head', '_admin_bar_bump_cb');
}
function nap_attribute_by_category($categorie, $attr) {
......@@ -726,13 +761,11 @@ function nap_attribute_by_category($categorie, $attr) {
$products = get_posts($args);
$attribute = array();
foreach ($products as $key => $value) {
if($attr == 'pa_couleur')
{
$list_attr = wc_get_product_terms($value->ID, $attr,array( 'fields' => 'ids' ));
if ($attr == 'pa_couleur') {
$list_attr = wc_get_product_terms($value->ID, $attr, array('fields' => 'ids'));
} else {
$list_attr = woocommerce_get_product_terms($value->ID, $attr, 'names');
}
else
{ $list_attr = woocommerce_get_product_terms($value->ID, $attr, 'names');}
// print_r($list_attr);
foreach ($list_attr as $key => $value) {
$attribute[] = $value;
......@@ -767,18 +800,17 @@ function nap_trash_fiche_technique($post_id) {
$wpdb->delete($table, array('meta_key' => 'fiche_var_auto', 'meta_value' => $post->post_title));
}
add_action('pre_get_posts', 'nap_change_filter_post');
add_action( 'pre_get_posts', 'nap_change_filter_post' );
function nap_change_filter_post() {
global $wp_query;
if(is_admin()) {
if(!empty($wp_query->query_vars['product_cat'])) {
if (is_admin()) {
if (!empty($wp_query->query_vars['product_cat'])) {
setcookie("product_cat", $wp_query->query_vars['product_cat']);
}
if(!isset($_GET['product_cat']) && ($_GET['post_type'] == 'product')) {
if (!isset($_GET['product_cat']) && ($_GET['post_type'] == 'product')) {
$wp_query->query_vars['product_cat'] = $_COOKIE['product_cat'];
}
elseif(isset($_GET['product_cat']) && empty($_GET['product_cat'])) {
} elseif (isset($_GET['product_cat']) && empty($_GET['product_cat'])) {
setcookie("product_cat", $wp_query->query_vars['product_cat']);
}
}
......@@ -786,43 +818,86 @@ function nap_change_filter_post() {
function nap_show_associated_products() {
$associated_products = '';
global $product;
$upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $product->get_upsell_ids() ), 'wc_products_array_filter_visible' ), 'rand', 'desc' );
$upsells = wc_products_array_orderby(array_filter(array_map('wc_get_product', $product->get_upsell_ids()), 'wc_products_array_filter_visible'), 'rand', 'desc');
$associated_products .= '<div class="suggest-header">
<h2>Produits associés</h2>
<span class="close-btn"></span>
</div>
<div class="product-list-content">';
foreach ( $upsells as $upsell ) :
foreach ($upsells as $upsell) :
$img = '';
if(has_post_thumbnail($upsell->get_id()))
if (has_post_thumbnail($upsell->get_id()))
$img = get_the_post_thumbnail($upsell->get_id(), 'medium');
else {
$product = new WC_Product_Variable( $upsell->get_id() );
else {
$product = new WC_Product_Variable($upsell->get_id());
$variations = $product->get_available_variations();
if(isset($variations[0]))
if (isset($variations[0]))
$img = get_the_post_thumbnail($variations[0]['variation_id'], 'medium');
}
$associated_products .= '<article class = "row full-width">
<a href="#"></a>
<figure>
'.$img.'
' . $img . '
</figure>
<h3 class = "font-small" >'. $upsell->name .'</h3>
<h3 class = "font-small" >' . $upsell->name . '</h3>
</article>';
endforeach;
$associated_products .= '</div>';
return $associated_products;
}
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 100;
function custom_wc_ajax_variation_threshold($qty, $product) {
return 100;
}
add_filter('woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2);
function nap_var_fiche($available_variations) {
$variation_hasFiche = '';
foreach ($available_variations as $key => $value) {
// print $key.'-'.get_post_meta($value['variation_id'], '_var_fiche', true)."<br />";
$fiche = get_post_meta($value['variation_id'], '_var_fiche', true);
if ($fiche) {
$variation_hasFiche .= $value['variation_id'] . ',';
}
}
echo $variation_hasFiche;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
add_filter( 'wpseo_metadesc', function( $description )
{ global $product;
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
return
( is_product() || (isset($product) && $product->is_type( 'variable' )) )
? $terms[1]->description
: $description;
}, PHP_INT_MAX );
function get_product_by_sku( $sku ) {
global $wpdb;
$post_item = $wpdb->get_results("SELECT post_id FROM np_postmeta WHERE meta_key='_sku' AND meta_value=".$sku." LIMIT 1");
return $post_item;
return null;
}
......@@ -53,7 +53,7 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
<span>Filtres</span>
<span class="close-btn"></span>
</div>
<input type="text" name ="sku-search" placeholder="Référence" id="sku-search"/>
<?php
$attributes = array('Univers' => 'pa_univers', 'Matiére' => 'pa_matiere', 'Format' => 'pa_format', 'Couleurs' => 'pa_couleur');
foreach ($attributes as $key => $value) :
......@@ -148,7 +148,7 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
</div>
<div class="right-panel right">
<div class="panel panel-content list-animation">
<?php if ($_GET['pa_couleur'] != '' || $_GET['pa_format'] != '' || $_GET['pa_matiere'] != ''): ?>
<?php if ($_GET['pa_couleur'] != '' || $_GET['pa_format'] != '' || $_GET['pa_matiere'] != '' || $_GET['pa_univers'] != '' || $_GET['sku'] != ''): ?>
<span class="search_result">Résultat de votre recherche :<span class="search_notfound" style="color:#ff6a5f"></span></span>
<?php endif; ?>
......
......@@ -85,14 +85,13 @@ do_action('woocommerce_before_add_to_cart_form');
<div class="gallery clearfix">
<div class="gallery-content clearfix">
<span class="close-btn"></span>
<article class = "row" data-color = "<?php echo get_post_thumbnail_id($ID) ?>">
<?php if ( is_user_logged_in() ) { ?>
<a class = "download-btn" href="<?php echo get_the_post_thumbnail_url($ID, 'full') ?>" download></a>
<?php } ?>
<figure>
<img src="<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>" alt="" title="">
<img src="<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>" alt="<?php echo get_the_title($ID)?>" title="">
</figure>
</article>
<?php
......@@ -107,7 +106,7 @@ do_action('woocommerce_before_add_to_cart_form');
<a class = "download-btn" href="<?php echo $hd[0]; ?>" download></a>
<?php } ?>
<figure>
<img src="<?php echo $attachment[0]; ?>" alt="" title="">
<img src="<?php echo $attachment[0]; ?>" alt="<?php echo get_the_title($ID)?>" title="">
</figure>
</article>
<?php
......@@ -130,7 +129,7 @@ do_action('woocommerce_before_add_to_cart_form');
<?php
$format = $product->get_attribute( 'pa_format' );?>
<h2 class = "crete font-small" ><?php echo $sub_cat[0]->name ?></h2>
<h3 class = "crete font-small info-attr" ><span class="info-format"><?php echo $format; ?></span> <span class="info-color"><?php echo$_GET['pa_couleur'] ?></span></h3>
<h1 class = "crete font-small info-attr" ><span class="info-format"><?php echo $format; ?></span> <span class="info-color"><?php echo$_GET['pa_couleur'] ?></span></h1>
<div class="details font-small">
<p class="info-format-txt">
<?php echo $format; ?>
......
......@@ -37,11 +37,18 @@ if (!function_exists('print_attribute_radio')) {
function print_attribute_radio($checked_value, $value, $label, $name, $index=0) {
$current_color = $_GET['pa_couleur'];
$current_taille = $_GET['pa_taille'];
$selected = $default_checked = "";
if ($value == strtolower($current_color)){
$default_checked = "checked";
$selected = "selected";
}
if ($value == strtolower($current_taille)){
$default_checked = "checked";
$selected = "selected";
}
$checked = sanitize_title($checked_value) === $checked_value ? checked($checked_value, sanitize_title($value), false) : checked($checked_value, $value, false);
......@@ -78,7 +85,7 @@ if (!function_exists('print_attribute_radio')) {
'<img src="'.$default_active.'" class="active" id="'.$value.'-active" style ="height:35px;width:35px" alt="">';
}
$filtered_label = apply_filters('woocommerce_variation_option_name', $label);
printf('<li class="format-list '.$input_name.'"><input type="radio" name="%1$s" value="%2$s" id="%3$s" %4$s>
printf('<li class="format-list '.$input_name.' '.$selected.'"><input type="radio" name="%1$s" value="%2$s" id="%3$s" %4$s '. $default_checked .'>
<label class="format-label" for="xx%3$s">'.$format_img.'</label>
<div class="format-desc">'.$label.'</div>
......@@ -124,9 +131,10 @@ do_action('woocommerce_before_add_to_cart_form');
foreach ($var_colors as $key => $value) :
?>
<div style="background-image:url('<?php echo get_the_post_thumbnail_url($key, 'medium') ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-color = "<?php echo $value ?>" data-slick-index = "1">
<a href="<?php echo get_the_post_thumbnail_url($key, 'full') ?>">
<a href="<?php echo get_the_post_thumbnail_url($key, 'large') ?>" data-standard="<?php echo get_the_post_thumbnail_url($key, 'medium') ?>">
<!--<img src="<?php echo get_the_post_thumbnail_url($key, 'medium') ?>" alt="" />-->
</a>
<div class="loading-hd"></div>
</div>
<?php
......@@ -166,7 +174,7 @@ do_action('woocommerce_before_add_to_cart_form');
<a class = "download-btn" href="<?php echo get_the_post_thumbnail_url($key, 'full') ?>" download></a>
<?php } ?>
<figure>
<img src="<?php echo get_the_post_thumbnail_url($key, 'medium') ?>" alt="" title="">
<img src="<?php echo get_the_post_thumbnail_url($key, 'medium') ?>" alt="<?php echo get_the_title($ID)?>" title="">
</figure>
</article>
<?php
......@@ -182,7 +190,7 @@ do_action('woocommerce_before_add_to_cart_form');
<a class = "download-btn" href="<?php echo $hd[0]; ?>" download></a>
<?php } ?>
<figure>
<img src="<?php echo $attachment[0]; ?>" alt="" title="">
<img src="<?php echo $attachment[0]; ?>" alt="<?php echo get_the_title($ID)?>" title="">
</figure>
</article>
<?php
......@@ -196,22 +204,24 @@ do_action('woocommerce_before_add_to_cart_form');
</div>
</div>
</div>
<div class="product-details full-height row right clearfix transition">
<form class="variations_form cart left row" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint($product->get_id()); ?>" data-product_variations="<?php echo htmlspecialchars(wp_json_encode($available_variations)) ?>">
<?php do_action('woocommerce_before_variations_form'); ?>
<?php if (empty($available_variations) && false !== $available_variations) : ?>
<p class="stock out-of-stock"><?php _e('This product is currently out of stock and unavailable.', 'woocommerce'); ?></p>
<?php else : ?>
<div class="variations" cellspacing="0">
<?php
$i=0;
foreach ($attributes as $name => $options) : ?>
<div class="list row <?php echo $name;?> left border-l center">
<div class="list row <?php echo $name;?> left border-l center <?php if($i==0) echo "first_attr" ;?>">
<div class="product-header center font-small label">
<label for="<?php echo sanitize_title($name); ?>" class = "chevron bottom"> <?php if($i==0) /*echo 'choix de la '*/; else /*echo 'choix du '*/; ?><?php echo strtolower(wc_attribute_label($name)); ?></label>
......@@ -225,6 +235,8 @@ do_action('woocommerce_before_add_to_cart_form');
} else {
$checked_value = '';
}
?>
<div class="list-wrapper">
<ul class="value">
......@@ -285,7 +297,7 @@ do_action('woocommerce_before_add_to_cart_form');
$format = $format_info->name;?>
<h2 class = "crete font-small" ><?php echo $sub_cat[0]->name; ?></h2>
<h3 class = "crete font-small info-attr" ><span class="info-format"><?php echo $format ; ?></span> <span class="info-color"><?php echo$_GET['pa_couleur'] ?></span></h3>
<h1 class = "crete font-small info-attr" ><span class="info-format"><?php echo $format ; ?></span> <span class="info-color"><?php echo$_GET['pa_couleur'] ?></span></h1>
<div class="details font-small">
<p class="info-format-txt"><?php echo $format; ?></p>
<p class="pq"><?php echo nap_variable_meta($current_variationID, 'variation_description'); ?></p>
......@@ -314,7 +326,7 @@ do_action('woocommerce_before_add_to_cart_form');
</div>
<div class = "btn-list">
<a href="<?php echo get_permalink(157); ?>" class="btn pink-btn rounded">Nous contacter</a>
<a class="btn pink-btn rounded download-btn download_file">Télécharger la fiche technique </a>
<a class="btn pink-btn rounded download-btn download_file" data-fiche="<?php nap_var_fiche($available_variations);?>">Télécharger la fiche technique </a>
<a href="<?php echo get_permalink(43); ?>?product_id=<?php echo $product->get_id()?>&" class="hidden download_file_link" id="<?php echo $current_variationID ?>"></a>
</div>
<?php if(count($product->get_upsell_ids())):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment