Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
NAP-wordpress
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marwa Sfari
NAP-wordpress
Commits
ac261a42
Commit
ac261a42
authored
Jul 20, 2017
by
Nahla Shiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
variation js style
parent
85535e53
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
72 deletions
+79
-72
main.js
wp-content/themes/nap/assets/js/main.js
+10
-5
nap.js
wp-content/themes/nap/assets/js/nap.js
+11
-12
product.js
wp-content/themes/nap/assets/js/product.js
+10
-2
functions.php
wp-content/themes/nap/functions.php
+3
-10
variable.php
...s/nap/woocommerce/single-product/add-to-cart/variable.php
+45
-43
No files found.
wp-content/themes/nap/assets/js/main.js
View file @
ac261a42
...
@@ -53,6 +53,8 @@ $(function(){
...
@@ -53,6 +53,8 @@ $(function(){
$
(
document
).
on
(
'click'
,
'.acces li'
,
function
(
e
){
$
(
document
).
on
(
'click'
,
'.acces li'
,
function
(
e
){
e
.
stopImmediatePropagation
();
e
.
stopImmediatePropagation
();
$
(
'.popup-container'
).
fadeIn
();
$
(
'.popup-container'
).
fadeIn
();
// $('#user_login').attr('placeholder', 'Identifiant');
// $('#user_pass').attr('placeholder', 'Mot de passe');
$
(
'.popup-first'
).
removeClass
(
'fadeOutDown '
).
addClass
(
'animated visible-elem pulse'
);
$
(
'.popup-first'
).
removeClass
(
'fadeOutDown '
).
addClass
(
'animated visible-elem pulse'
);
});
});
...
@@ -278,12 +280,11 @@ $.fn.getMenuBg = function(){
...
@@ -278,12 +280,11 @@ $.fn.getMenuBg = function(){
navHeader
=
$
(
'.nav-header'
).
outerHeight
(),
navHeader
=
$
(
'.nav-header'
).
outerHeight
(),
containerHeight
=
windowHeight
-
footerHeight
,
containerHeight
=
windowHeight
-
footerHeight
,
navPhototequeWidth
=
$
(
'.nav-phototeque'
).
outerWidth
(),
navPhototequeWidth
=
$
(
'.nav-phototeque'
).
outerWidth
(),
maxHeight
=
productHeight
>
windowHeight
?
productHeight
-
footerHeight
:
containerHeight
-
foot
erHeight
,
maxHeight
=
productHeight
>
windowHeight
?
productHeight
:
contain
erHeight
,
galleryWidth
=
windowWidth
-
navPhototequeWidth
,
galleryWidth
=
windowWidth
-
navPhototequeWidth
,
filterWidth
=
$
(
'.right-container .left-panel'
).
outerWidth
(),
filterWidth
=
$
(
'.right-container .left-panel'
).
outerWidth
(),
footerContact
=
$
(
'.contact-form .footer'
).
outerHeight
(),
footerContact
=
$
(
'.contact-form .footer'
).
outerHeight
();
sizeProductDetails
=
$
(
'.product-details >div'
).
length
;
if
(
sizeProductDetails
<=
2
)
$
(
'.product-info'
).
outerWidth
(
'78.3%'
);
$
(
'.gallery-wrapper'
).
outerWidth
(
galleryWidth
).
css
(
'margin-left'
,
navPhototequeWidth
)
;
$
(
'.gallery-wrapper'
).
outerWidth
(
galleryWidth
).
css
(
'margin-left'
,
navPhototequeWidth
)
;
$
(
'.main,.load-page'
).
outerHeight
(
containerHeight
);
$
(
'.main,.load-page'
).
outerHeight
(
containerHeight
);
$
(
'.full-height'
).
outerHeight
(
maxHeight
);
$
(
'.full-height'
).
outerHeight
(
maxHeight
);
...
@@ -296,6 +297,11 @@ $.fn.getMenuBg = function(){
...
@@ -296,6 +297,11 @@ $.fn.getMenuBg = function(){
$
(
'.contact-form .inner-form'
).
outerHeight
(
windowHeight
-
footerContact
);
$
(
'.contact-form .inner-form'
).
outerHeight
(
windowHeight
-
footerContact
);
$
(
'#catalogue .panel-content section'
).
last
().
height
(
windowHeight
-
footerHeight
);
$
(
'#catalogue .panel-content section'
).
last
().
height
(
windowHeight
-
footerHeight
);
}
}
//Wordpress js login
$
(
'#user_login'
).
attr
(
'placeholder'
,
'Identifiant'
);
$
(
'#user_pass'
).
attr
(
'placeholder'
,
'Mot de passe'
);
$
(
"#user_login"
).
addClass
(
"my-login-username"
);
});
//END Function
});
//END Function
function
animateOnScroll
(){
function
animateOnScroll
(){
...
@@ -410,7 +416,6 @@ function scrollAnchor(elemId, skipZero){
...
@@ -410,7 +416,6 @@ function scrollAnchor(elemId, skipZero){
});
});
});
});
}
}
$
(
window
).
load
(
function
()
{
$
(
window
).
load
(
function
()
{
initFunction
();
initFunction
();
});
//END document load
});
//END document load
...
...
wp-content/themes/nap/assets/js/nap.js
View file @
ac261a42
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
document
).
ready
(
function
()
{
jQuery
(
".download_file"
).
click
(
function
()
{
jQuery
(
document
).
on
(
'click'
,
".download_file"
,
function
()
{
var
id
;
var
download_link
=
jQuery
(
'.download_file_link'
).
attr
(
'href'
);
var
download_link
=
jQuery
(
'.download_file_link'
).
attr
(
'href'
);
var
variation_id
=
jQuery
(
'input[name="variation_id"]'
).
val
();
var
current_var
=
jQuery
(
'.download_file_link'
).
attr
(
'id'
);
var
link
=
download_link
+
'?variation_id='
+
variation_id
;
var
variation_id
=
jQuery
(
'input[name="variation_id"]'
).
val
();
alert
(
link
);
if
(
variation_id
==
0
)
window
.
location
.
href
=
link
;
id
=
current_var
;
else
id
=
variation_id
;
var
link
=
download_link
+
'?variation_id='
+
id
;
window
.
open
(
link
,
'_blank'
);
return
false
;
return
false
;
});
});
jQuery
(
'.color-list'
).
each
(
function
(
index
,
value
)
{
var
color
=
jQuery
(
this
).
find
(
'input'
).
attr
(
'data-color'
);
jQuery
(
this
).
find
(
'input[type=radio]:after'
).
css
(
'background-color'
,
color
);
});
});
});
\ No newline at end of file
wp-content/themes/nap/assets/js/product.js
View file @
ac261a42
...
@@ -132,6 +132,13 @@ $(function(){
...
@@ -132,6 +132,13 @@ $(function(){
var
toLink
=
$
(
this
).
data
(
'link'
);
var
toLink
=
$
(
this
).
data
(
'link'
);
$
(
'.load-page'
).
parent
().
addClass
(
'active'
);
$
(
'.load-page'
).
parent
().
addClass
(
'active'
);
$
(
'.load-page'
).
load
(
toLink
,
function
(){
$
(
'.load-page'
).
load
(
toLink
,
function
(){
sizeProductDetails
=
$
(
'.product-details .list'
).
length
;
if
(
sizeProductDetails
<
2
)
{
$
(
'.product-info'
).
outerWidth
(
'78.3%'
);
console
.
log
(
sizeProductDetails
);
}
$
(
'.list-color li'
).
getListColors
();
$
(
'.list-color li'
).
getListColors
();
$
(
'.list-color li'
).
selectColor
();
$
(
'.list-color li'
).
selectColor
();
$
(
'.list-format li'
).
selectFormat
();
$
(
'.list-format li'
).
selectFormat
();
...
@@ -139,6 +146,7 @@ $(function(){
...
@@ -139,6 +146,7 @@ $(function(){
$
(
'article[data-color], .list-color li span'
).
selectSlide
(
$
(
'#slides'
));
$
(
'article[data-color], .list-color li span'
).
selectSlide
(
$
(
'#slides'
));
$
(
'#mozaique'
).
open_gallery
();
$
(
'#mozaique'
).
open_gallery
();
initFunction
();
initFunction
();
$
.
fn
.
responsive
();
$
(
'html'
).
css
(
'overflow'
,
'hidden'
);
$
(
'html'
).
css
(
'overflow'
,
'hidden'
);
setTimeout
(
function
(){
setTimeout
(
function
(){
$
.
fn
.
productAnimation
();
$
.
fn
.
productAnimation
();
...
@@ -146,8 +154,8 @@ $(function(){
...
@@ -146,8 +154,8 @@ $(function(){
$
.
fn
.
slider_product
();
$
.
fn
.
slider_product
();
$
(
'.list-color li'
).
selectColor
();
$
(
'.list-color li'
).
selectColor
();
$
(
'.list-format li'
).
selectFormat
();
$
(
'.list-format li'
).
selectFormat
();
},
5
00
)
},
9
00
)
$
(
'.download-btn'
).
click
(
function
(
e
){
$
(
'.download-btn
:not(.download_file)
'
).
click
(
function
(
e
){
e
.
stopPropagation
();
e
.
stopPropagation
();
});
});
});
});
...
...
wp-content/themes/nap/functions.php
View file @
ac261a42
...
@@ -443,15 +443,8 @@ function nap_upload_image($img){
...
@@ -443,15 +443,8 @@ function nap_upload_image($img){
return
trim
(
strtolower
(
$img
));
return
trim
(
strtolower
(
$img
));
}
}
function
nap_print_attribute_radio
(
$checked_value
,
$value
,
$label
,
$name
)
{
function
nap_variable_meta
(
$varID
,
$meta
){
$checked
=
sanitize_title
(
$checked_value
)
===
$checked_value
?
checked
(
$checked_value
,
sanitize_title
(
$value
),
false
)
:
checked
(
$checked_value
,
$value
,
false
);
return
get_post_meta
(
$varID
,
'_'
.
$meta
,
true
);
}
$input_name
=
'attribute_'
.
esc_attr
(
$name
)
;
$esc_value
=
esc_attr
(
$value
);
$id
=
esc_attr
(
$name
.
'_v_'
.
$value
);
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
printf
(
'<div><input type="radio" name="%1$s" value="%2$s" id="%3$s" %4$s><label for="%3$s">%5$s</label></div>'
,
$input_name
,
$esc_value
,
$id
,
$checked
,
$filtered_label
);
}
\ No newline at end of file
wp-content/themes/nap/woocommerce/single-product/add-to-cart/variable.php
View file @
ac261a42
...
@@ -38,18 +38,17 @@
...
@@ -38,18 +38,17 @@
width
:
100px
;
width
:
100px
;
height
:
70px
;
height
:
70px
;
}
}
.reset_variations
,
.quantity
{
.reset_variations
,
.quantity
{
display
:
none
!important
;
display
:
none
!important
;
}
}
</style>
</style>
<?php
<?php
print_r
(
$_GET
);
print_r
(
$_POST
);
/**
/**
* Variable product add to cart
* Variable product add to cart
*
*
...
@@ -76,10 +75,15 @@ $attribute_keys = array_keys($attributes);
...
@@ -76,10 +75,15 @@ $attribute_keys = array_keys($attributes);
$product_cats
=
array_reverse
(
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
));
$product_cats
=
array_reverse
(
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
));
$subcat_iD
=
$product_cats
[
1
]
->
term_id
;
$subcat_iD
=
$product_cats
[
1
]
->
term_id
;
$current_variationID
=
$_GET
[
'variation_id'
];
if
(
!
function_exists
(
'print_attribute_radio'
))
{
if
(
!
function_exists
(
'print_attribute_radio'
))
{
function
print_attribute_radio
(
$checked_value
,
$value
,
$label
,
$name
)
{
function
print_attribute_radio
(
$checked_value
,
$value
,
$label
,
$name
)
{
$current_color
=
$_GET
[
'attribute_couleur'
];
$default_checked
=
""
;
if
(
$value
==
strtolower
(
$current_color
))
$default_checked
=
"checked"
;
$checked
=
sanitize_title
(
$checked_value
)
===
$checked_value
?
checked
(
$checked_value
,
sanitize_title
(
$value
),
false
)
:
checked
(
$checked_value
,
$value
,
false
);
$checked
=
sanitize_title
(
$checked_value
)
===
$checked_value
?
checked
(
$checked_value
,
sanitize_title
(
$value
),
false
)
:
checked
(
$checked_value
,
$value
,
false
);
$input_name
=
'attribute_'
.
esc_attr
(
$name
);
$input_name
=
'attribute_'
.
esc_attr
(
$name
);
...
@@ -91,7 +95,7 @@ if (!function_exists('print_attribute_radio')) {
...
@@ -91,7 +95,7 @@ if (!function_exists('print_attribute_radio')) {
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
printf
(
' <style>
printf
(
' <style>
#'
.
$id
.
':after { background-color: '
.
$hexa
.
'; }
#'
.
$id
.
':after { background-color: '
.
$hexa
.
'; }
</style><li class="color-list" data-color="'
.
$hexa
.
'"><input data-color="'
.
$hexa
.
'" type="radio" name="%1$s" value="%2$s" id="%3$s" %4$s><span data-color="'
.
$hexa
.
'"></span></li>'
,
$input_name
,
$esc_value
,
$id
,
$checked
,
$filtered_label
);
</style><li class="color-list" data-color="'
.
$hexa
.
'"><input data-color="'
.
$hexa
.
'" type="radio" name="%1$s" value="%2$s" id="%3$s" %4$s
'
.
$default_checked
.
'
><span data-color="'
.
$hexa
.
'"></span></li>'
,
$input_name
,
$esc_value
,
$id
,
$checked
,
$filtered_label
);
}
else
{
}
else
{
$icons
=
nap_icon_format
(
$value
);
$icons
=
nap_icon_format
(
$value
);
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
...
@@ -196,7 +200,7 @@ do_action('woocommerce_before_add_to_cart_form');
...
@@ -196,7 +200,7 @@ do_action('woocommerce_before_add_to_cart_form');
<div
class=
"product-details full-height row right clearfix transition"
>
<div
class=
"product-details full-height row right clearfix transition"
>
<form
class=
"variations_form cart"
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
))
?>
"
>
<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
do_action
(
'woocommerce_before_variations_form'
);
?>
<?php
if
(
empty
(
$available_variations
)
&&
false
!==
$available_variations
)
:
?>
<?php
if
(
empty
(
$available_variations
)
&&
false
!==
$available_variations
)
:
?>
...
@@ -270,12 +274,12 @@ do_action('woocommerce_before_add_to_cart_form');
...
@@ -270,12 +274,12 @@ do_action('woocommerce_before_add_to_cart_form');
<span class = "chevron bottom">Choix de la couleur</span>
<span class = "chevron bottom">Choix de la couleur</span>
</div>
</div>
<ul>
<ul>
<?php
<?php
foreach
(
$var_colors
as
$key
=>
$value
)
:
foreach
(
$var_colors
as
$key
=>
$value
)
:
$variable_product
=
wc_get_product
(
$key
);
$variable_product
=
wc_get_product
(
$key
);
?>
?>
<li class = "" data-name='
<?php
echo
$variable_product
->
get_attribute
(
'couleur'
);
?>
'><span data-color="
<?php
echo
$value
;
?>
"></span></li>
<li class = "" data-name='
<?php
echo
$variable_product
->
get_attribute
(
'couleur'
);
?>
'><span data-color="
<?php
echo
$value
;
?>
"></span></li>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</ul>
</ul>
</div>
</div>
...
@@ -284,63 +288,61 @@ do_action('woocommerce_before_add_to_cart_form');
...
@@ -284,63 +288,61 @@ do_action('woocommerce_before_add_to_cart_form');
<span class = "chevron bottom">Choix du format</span>
<span class = "chevron bottom">Choix du format</span>
</div>
</div>
<ul>
<ul>
<?php
<?php
$formats_tab
=
nap_distinct_format_variations
(
$variations
);
$formats_tab
=
nap_distinct_format_variations
(
$variations
);
foreach
(
$formats_tab
as
$key
=>
$value
)
:
foreach
(
$formats_tab
as
$key
=>
$value
)
:
$icons
=
nap_icon_format
(
$key
);
$icons
=
nap_icon_format
(
$key
);
$term
=
get_term_by
(
'name'
,
$value
,
'pa_format'
);
$term
=
get_term_by
(
'name'
,
$value
,
'pa_format'
);
// print_r($term);
// print_r($term);
?>
?>
<li class ="" data-format='
<?php
echo
$term
->
slug
;
?>
'>
<li class ="" data-format='
<?php
echo
$term
->
slug
;
?>
'>
<img src="
<?php
echo
$icons
[
'inactive'
]
?>
" data-img = "
<?php
echo
$icons
[
'inactive'
]
?>
" data-img-active = '
<?php
echo
$icons
[
'active'
]
?>
'>
<img src="
<?php
echo
$icons
[
'inactive'
]
?>
" data-img = "
<?php
echo
$icons
[
'inactive'
]
?>
" data-img-active = '
<?php
echo
$icons
[
'active'
]
?>
'>
<div class="format-desc">
<?php
echo
$value
?>
</div>
<div class="format-desc">
<?php
echo
$value
?>
</div>
</li>
</li>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</ul>
</ul>
</div>-->
</div>-->
<div
class=
"product-info row center left border-l"
>
</form>
<div
class=
"product-info row center left border-l"
>
<div
class=
"info-content"
>
<div
class=
"info-content"
>
<h2
class =
"crete -italic font-small"
>
<?php
echo
$product_cats
[
1
]
->
name
?>
</h2>
<h2
class =
"crete -italic font-small"
>
<?php
echo
$product_cats
[
1
]
->
name
?>
</h2>
<h3
class =
"crete -italic font-small"
>
39x39 abricot
</h3>
<h3
class =
"crete -italic font-small"
>
39x39 abricot
</h3>
<div
class=
"details font-small"
>
<div
class=
"details font-small"
>
<p>
39 x 39 cm - 2 feuilles
</p>
<p>
39 x 39 cm - 2 feuilles
</p>
<p>
18 paquets de 100
</p>
<p>
<?php
echo
nap_variable_meta
(
$current_variationID
,
'variation_description'
);
?>
</p>
</div>
</div>
<div
class=
"price"
>
<div
class=
"price"
>
<span
class=
"crete"
>
<?php
echo
$product
->
get_price_html
();
?>
ht
</span>
<span
class=
"crete"
>
<?php
echo
nap_variable_meta
(
$current_variationID
,
'price'
);
?>
€
ht
</span>
<div
class=
"notice"
>
( prix public conseillé )
</div>
<div
class=
"notice"
>
( prix public conseillé )
</div>
<div
class=
"font-small"
>
<div
class=
"font-small"
>
<div
class=
"product_meta"
>
<div
class=
"product_meta"
>
<?php
do_action
(
'woocommerce_product_meta_start'
);
?>
<?php
do_action
(
'woocommerce_product_meta_start'
);
?>
<?php
if
(
wc_product_sku_enabled
()
&&
(
$product
->
get_sku
()
||
$product
->
is_type
(
'variable'
)
)
)
:
?>
<?php
if
(
wc_product_sku_enabled
()
&&
(
$product
->
get_sku
()
||
$product
->
is_type
(
'variable'
)
)
)
:
?>
<span
class=
"sku_wrapper"
><span
class=
"sku"
>
<?php
echo
(
$sku
=
$product
->
get_sku
()
)
?
$sku
:
esc_html__
(
'N/A'
,
'woocommerce'
);
?>
</span></span>
<span
class=
"sku_wrapper"
><span
class=
"sku"
>
<?php
echo
(
$sku
=
$product
->
get_sku
()
)
?
$sku
:
nap_variable_meta
(
$current_variationID
,
'sku'
);
?>
</span></span>
<?php
endif
;
?>
<?php
endif
;
?>
<?php
do_action
(
'woocommerce_product_meta_end'
);
?>
</div>
<?php
do_action
(
'woocommerce_product_meta_end'
);
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class =
"btn-list"
>
<div
class =
"btn-list"
>
<div
class=
"btn pink-btn rounded"
>
Nous contacter
</div>
<a
href=
"
<?php
echo
get_permalink
(
157
);
?>
"
class=
"btn pink-btn rounded"
>
Nous contacter
</a>
<div
class=
"btn pink-btn rounded download-btn"
>
<a
class=
"btn pink-btn rounded download-btn download_file"
>
Télécharger la fiche technique
</a>
<a
href=
"
<?php
echo
get_permalink
(
43
);
?>
"
class=
"hidden download_file_link"
></a>
<a
href=
"
<?php
echo
get_permalink
(
43
);
?>
"
class=
"hidden download_file_link"
id=
"
<?php
echo
$current_variationID
?>
"
></a>
<a
href=
"#"
class=
"download_file"
>
Télécharger la fiche technique
</a>
</div>
</div>
</div>
<div
class=
"font-small circle-btn add-icon show-product"
><span
class=
"abs-center"
>
Produits associées
</span></div>
<div
class=
"font-small circle-btn add-icon show-product"
><span
class=
"abs-center"
>
Produits associées
</span></div>
</div>
</div>
</form>
</div>
</div>
<div
class=
"product-list transition border-l fixed"
>
<div
class=
"product-list transition border-l fixed"
>
<div
class=
"suggest-header"
>
<div
class=
"suggest-header"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment