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(){
$
(
document
).
on
(
'click'
,
'.acces li'
,
function
(
e
){
e
.
stopImmediatePropagation
();
$
(
'.popup-container'
).
fadeIn
();
// $('#user_login').attr('placeholder', 'Identifiant');
// $('#user_pass').attr('placeholder', 'Mot de passe');
$
(
'.popup-first'
).
removeClass
(
'fadeOutDown '
).
addClass
(
'animated visible-elem pulse'
);
});
...
...
@@ -278,12 +280,11 @@ $.fn.getMenuBg = function(){
navHeader
=
$
(
'.nav-header'
).
outerHeight
(),
containerHeight
=
windowHeight
-
footerHeight
,
navPhototequeWidth
=
$
(
'.nav-phototeque'
).
outerWidth
(),
maxHeight
=
productHeight
>
windowHeight
?
productHeight
-
footerHeight
:
containerHeight
-
foot
erHeight
,
maxHeight
=
productHeight
>
windowHeight
?
productHeight
:
contain
erHeight
,
galleryWidth
=
windowWidth
-
navPhototequeWidth
,
filterWidth
=
$
(
'.right-container .left-panel'
).
outerWidth
(),
footerContact
=
$
(
'.contact-form .footer'
).
outerHeight
(),
sizeProductDetails
=
$
(
'.product-details >div'
).
length
;
if
(
sizeProductDetails
<=
2
)
$
(
'.product-info'
).
outerWidth
(
'78.3%'
);
footerContact
=
$
(
'.contact-form .footer'
).
outerHeight
();
$
(
'.gallery-wrapper'
).
outerWidth
(
galleryWidth
).
css
(
'margin-left'
,
navPhototequeWidth
)
;
$
(
'.main,.load-page'
).
outerHeight
(
containerHeight
);
$
(
'.full-height'
).
outerHeight
(
maxHeight
);
...
...
@@ -296,6 +297,11 @@ $.fn.getMenuBg = function(){
$
(
'.contact-form .inner-form'
).
outerHeight
(
windowHeight
-
footerContact
);
$
(
'#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
function
animateOnScroll
(){
...
...
@@ -410,7 +416,6 @@ function scrollAnchor(elemId, skipZero){
});
});
}
$
(
window
).
load
(
function
()
{
initFunction
();
});
//END document load
...
...
wp-content/themes/nap/assets/js/nap.js
View file @
ac261a42
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
variation_id
=
jQuery
(
'input[name="variation_id"]'
).
val
();
var
link
=
download_link
+
'?variation_id='
+
variation_id
;
alert
(
link
);
window
.
location
.
href
=
link
;
var
current_var
=
jQuery
(
'.download_file_link'
).
attr
(
'id'
);
var
variation_id
=
jQuery
(
'input[name="variation_id"]'
).
val
();
if
(
variation_id
==
0
)
id
=
current_var
;
else
id
=
variation_id
;
var
link
=
download_link
+
'?variation_id='
+
id
;
window
.
open
(
link
,
'_blank'
);
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(){
var
toLink
=
$
(
this
).
data
(
'link'
);
$
(
'.load-page'
).
parent
().
addClass
(
'active'
);
$
(
'.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'
).
selectColor
();
$
(
'.list-format li'
).
selectFormat
();
...
...
@@ -139,6 +146,7 @@ $(function(){
$
(
'article[data-color], .list-color li span'
).
selectSlide
(
$
(
'#slides'
));
$
(
'#mozaique'
).
open_gallery
();
initFunction
();
$
.
fn
.
responsive
();
$
(
'html'
).
css
(
'overflow'
,
'hidden'
);
setTimeout
(
function
(){
$
.
fn
.
productAnimation
();
...
...
@@ -146,8 +154,8 @@ $(function(){
$
.
fn
.
slider_product
();
$
(
'.list-color li'
).
selectColor
();
$
(
'.list-format li'
).
selectFormat
();
},
5
00
)
$
(
'.download-btn'
).
click
(
function
(
e
){
},
9
00
)
$
(
'.download-btn
:not(.download_file)
'
).
click
(
function
(
e
){
e
.
stopPropagation
();
});
});
...
...
wp-content/themes/nap/functions.php
View file @
ac261a42
...
...
@@ -443,15 +443,8 @@ function nap_upload_image($img){
return
trim
(
strtolower
(
$img
));
}
function
nap_print_attribute_radio
(
$checked_value
,
$value
,
$label
,
$name
)
{
$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
)
;
$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
);
}
function
nap_variable_meta
(
$varID
,
$meta
){
return
get_post_meta
(
$varID
,
'_'
.
$meta
,
true
);
}
\ 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 @@
width
:
100px
;
height
:
70px
;
}
.reset_variations
,
.quantity
{
display
:
none
!important
;
}
</style>
<?php
print_r
(
$_POST
);
print_r
(
$_GET
);
/**
* Variable product add to cart
*
...
...
@@ -76,10 +75,15 @@ $attribute_keys = array_keys($attributes);
$product_cats
=
array_reverse
(
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
));
$subcat_iD
=
$product_cats
[
1
]
->
term_id
;
$current_variationID
=
$_GET
[
'variation_id'
];
if
(
!
function_exists
(
'print_attribute_radio'
))
{
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
);
$input_name
=
'attribute_'
.
esc_attr
(
$name
);
...
...
@@ -91,7 +95,7 @@ if (!function_exists('print_attribute_radio')) {
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
printf
(
' <style>
#'
.
$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
{
$icons
=
nap_icon_format
(
$value
);
$filtered_label
=
apply_filters
(
'woocommerce_variation_option_name'
,
$label
);
...
...
@@ -196,7 +200,7 @@ do_action('woocommerce_before_add_to_cart_form');
<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
if
(
empty
(
$available_variations
)
&&
false
!==
$available_variations
)
:
?>
...
...
@@ -270,12 +274,12 @@ do_action('woocommerce_before_add_to_cart_form');
<span class = "chevron bottom">Choix de la couleur</span>
</div>
<ul>
<?php
foreach
(
$var_colors
as
$key
=>
$value
)
:
$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>
<?php
endforeach
;
?>
<?php
foreach
(
$var_colors
as
$key
=>
$value
)
:
$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>
<?php
endforeach
;
?>
</ul>
</div>
...
...
@@ -284,63 +288,61 @@ do_action('woocommerce_before_add_to_cart_form');
<span class = "chevron bottom">Choix du format</span>
</div>
<ul>
<?php
$formats_tab
=
nap_distinct_format_variations
(
$variations
);
foreach
(
$formats_tab
as
$key
=>
$value
)
:
$icons
=
nap_icon_format
(
$key
);
$term
=
get_term_by
(
'name'
,
$value
,
'pa_format'
);
// print_r($term);
?>
<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'
]
?>
'>
<div class="format-desc">
<?php
echo
$value
?>
</div>
</li>
<?php
endforeach
;
?>
<?php
$formats_tab
=
nap_distinct_format_variations
(
$variations
);
foreach
(
$formats_tab
as
$key
=>
$value
)
:
$icons
=
nap_icon_format
(
$key
);
$term
=
get_term_by
(
'name'
,
$value
,
'pa_format'
);
// print_r($term);
?>
<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'
]
?>
'>
<div class="format-desc">
<?php
echo
$value
?>
</div>
</li>
<?php
endforeach
;
?>
</ul>
</div>-->
<div
class=
"product-info row center left border-l"
>
</form>
<div
class=
"product-info row center left border-l"
>
<div
class=
"info-content"
>
<h2
class =
"crete -italic font-small"
>
<?php
echo
$product_cats
[
1
]
->
name
?>
</h2>
<h3
class =
"crete -italic font-small"
>
39x39 abricot
</h3>
<div
class=
"details font-small"
>
<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
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=
"font-small"
>
<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
do_action
(
'woocommerce_product_meta_end'
);
?>
</div>
<?php
do_action
(
'woocommerce_product_meta_end'
);
?>
</div>
</div>
</div>
</div>
<div
class =
"btn-list"
>
<div
class=
"btn pink-btn rounded"
>
Nous contacter
</div>
<div
class=
"btn pink-btn rounded download-btn"
>
<a
href=
"
<?php
echo
get_permalink
(
43
);
?>
"
class=
"hidden download_file_link"
></a>
<a
href=
"#"
class=
"download_file"
>
Télécharger la fiche technique
</a>
</div>
<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
href=
"
<?php
echo
get_permalink
(
43
);
?>
"
class=
"hidden download_file_link"
id=
"
<?php
echo
$current_variationID
?>
"
></a>
</div>
<div
class=
"font-small circle-btn add-icon show-product"
><span
class=
"abs-center"
>
Produits associées
</span></div>
</div>
</form>
</div>
<div
class=
"product-list transition border-l fixed"
>
<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