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
8b1c16df
Commit
8b1c16df
authored
Jul 19, 2017
by
Nahla Shiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
page variable
parent
bdeda2b7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
315 additions
and
325 deletions
+315
-325
functions.php
wp-content/themes/nap/functions.php
+86
-93
archive-product.php
wp-content/themes/nap/woocommerce/archive-product.php
+3
-1
single-product.php
wp-content/themes/nap/woocommerce/single-product.php
+3
-226
variable.php
...s/nap/woocommerce/single-product/add-to-cart/variable.php
+223
-5
No files found.
wp-content/themes/nap/functions.php
View file @
8b1c16df
<?php
<?php
@
ini_set
(
'upload_max_size'
,
'64M'
);
@
ini_set
(
'post_max_size'
,
'64M'
);
@
ini_set
(
'upload_max_size'
,
'64M'
);
@
ini_set
(
'max_execution_time'
,
'300'
);
@
ini_set
(
'post_max_size'
,
'64M'
);
@
ini_set
(
'max_execution_time'
,
'300'
);
//Get Zones
//Get Zones
function
get_zones
(
$post_ID
=
157
){
function
get_zones
(
$post_ID
=
157
)
{
if
(
get_field
(
'zones_commerciaux'
,
$post_ID
))
:
if
(
get_field
(
'zones_commerciaux'
,
$post_ID
))
:
$i
=
0
;
$i
=
0
;
while
(
has_sub_field
(
'zones_commerciaux'
,
$post_ID
))
:
while
(
has_sub_field
(
'zones_commerciaux'
,
$post_ID
))
:
if
(
get_sub_field
(
'list_zones'
,
$post_ID
))
:
if
(
get_sub_field
(
'list_zones'
,
$post_ID
))
:
$list_zone
=
array
();
$list_zone
=
array
();
while
(
has_sub_field
(
'list_zones'
,
$post_ID
))
:
while
(
has_sub_field
(
'list_zones'
,
$post_ID
))
:
$list_zone
[]
=
get_sub_field
(
'num_zone'
);
$list_zone
[]
=
get_sub_field
(
'num_zone'
);
endwhile
;
endwhile
;
endif
;
endif
;
$allZones
[
'zone'
.
$i
]
=
$list_zone
;
$allZones
[
'zone'
.
$i
]
=
$list_zone
;
$i
++
;
$i
++
;
endwhile
;
endwhile
;
endif
;
endif
;
return
json_encode
(
$allZones
);
return
json_encode
(
$allZones
);
}
}
//Dequeue CSS
//Dequeue CSS
function
nap_dequeue_unnecessary_css
()
{
function
nap_dequeue_unnecessary_css
()
{
wp_dequeue_style
(
'additional-parent-style'
);
wp_dequeue_style
(
'additional-parent-style'
);
...
@@ -42,12 +44,12 @@ function nap_dequeue_unnecessary_scripts() {
...
@@ -42,12 +44,12 @@ function nap_dequeue_unnecessary_scripts() {
wp_deregister_script
(
'twentyseventeen-navigation'
);
wp_deregister_script
(
'twentyseventeen-navigation'
);
//MS : 2017-07-17
//MS : 2017-07-17
wp_register_script
(
'getZones'
,
home_url
(
'wp-content/themes/nap/assets'
)
.
'/js/map.js'
);
wp_register_script
(
'getZones'
,
home_url
(
'wp-content/themes/nap/assets'
)
.
'/js/map.js'
);
$listZones
=
array
(
'listZones'
=>
get_zones
(
157
));
$listZones
=
array
(
'listZones'
=>
get_zones
(
157
));
wp_localize_script
(
'getZones'
,
'zonesL'
,
$listZones
);
wp_localize_script
(
'getZones'
,
'zonesL'
,
$listZones
);
// wp_localize_script( 'listZones', 'object_name', $listZones );
// wp_localize_script( 'listZones', 'object_name', $listZones );
wp_enqueue_script
(
'getZones'
);
wp_enqueue_script
(
'getZones'
);
//END MS : 2017-07-17
//END MS : 2017-07-17
}
}
...
@@ -245,7 +247,7 @@ function nap_load_variation_settings_fields($variations_id) {
...
@@ -245,7 +247,7 @@ function nap_load_variation_settings_fields($variations_id) {
function
nap_category_image
(
$catID
)
{
function
nap_category_image
(
$catID
)
{
$thumbnail_id
=
get_woocommerce_term_meta
(
$catID
,
'thumbnail_id'
,
true
);
$thumbnail_id
=
get_woocommerce_term_meta
(
$catID
,
'thumbnail_id'
,
true
);
$image
=
wp_get_attachment_image_src
(
$thumbnail_id
,
'large'
);
$image
=
wp_get_attachment_image_src
(
$thumbnail_id
,
'large'
);
return
$image
[
0
];
return
$image
[
0
];
}
}
...
@@ -255,37 +257,7 @@ function nap_attachment_image($pageID) {
...
@@ -255,37 +257,7 @@ function nap_attachment_image($pageID) {
return
$url
;
return
$url
;
}
}
/* add_action( 'woocommerce_after_shop_loop_item', 'nap_variations_loop' );
function
nap_menu
()
{
function nap_variations_loop(){
global $product;
$attributes = $product->get_attributes();
if ( ! $attributes ) {
echo "No attributes";
}
foreach ( $attributes as $attribute ) {
print_r($attribute);
echo $attribute['name'] . ": ";
$product_attributes = array();
$product_attributes = explode('|',$attribute['value']);
$attributes_dropdown = '<select>';
foreach ( $product_attributes as $pa ) {
$attributes_dropdown .= '<option value="' . $pa . '">' . $pa . '</option>';
}
$attributes_dropdown .= '</select>';
echo $attributes_dropdown;
}
}
*/
function
nap_menu
()
{
$menu
=
""
;
$menu
=
""
;
$taxonomy
=
'product_cat'
;
$taxonomy
=
'product_cat'
;
...
@@ -309,7 +281,7 @@ function nap_attachment_image($pageID) {
...
@@ -309,7 +281,7 @@ function nap_attachment_image($pageID) {
foreach
(
$all_categories
as
$cat
)
{
foreach
(
$all_categories
as
$cat
)
{
if
(
$cat
->
category_parent
==
0
)
{
if
(
$cat
->
category_parent
==
0
)
{
$category_id
=
$cat
->
term_id
;
$category_id
=
$cat
->
term_id
;
$menu
.=
'<li data-page = "'
.
$category_id
.
'" data-img = "'
.
nap_category_image
(
$category_id
)
.
'"><a href="'
.
get_term_link
(
$cat
->
slug
,
'product_cat'
)
.
'">'
.
$cat
->
name
.
'</a>'
;
$menu
.=
'<li 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
(
$args2
=
array
(
'taxonomy'
=>
$taxonomy
,
'taxonomy'
=>
$taxonomy
,
...
@@ -323,16 +295,16 @@ function nap_attachment_image($pageID) {
...
@@ -323,16 +295,16 @@ function nap_attachment_image($pageID) {
'hide_empty'
=>
1
'hide_empty'
=>
1
);
);
$sub_cats
=
get_categories
(
$args2
);
$sub_cats
=
get_categories
(
$args2
);
$menu
.=
' <ul class = "subcat" data-page = "'
.
$category_id
.
'">'
;
$menu
.=
' <ul class = "subcat" data-page = "'
.
$category_id
.
'">'
;
if
(
$sub_cats
)
{
if
(
$sub_cats
)
{
$class
=
''
;
$class
=
''
;
foreach
(
$sub_cats
as
$key
=>
$sub_category
)
{
foreach
(
$sub_cats
as
$key
=>
$sub_category
)
{
$subcat_name
=
explode
(
' '
,
$sub_category
->
name
);
$subcat_name
=
explode
(
' '
,
$sub_category
->
name
);
if
(
$key
==
0
)
if
(
$key
==
0
)
$calss
=
'active'
;
$calss
=
'active'
;
else
else
$calss
=
''
;
$calss
=
''
;
$menu
.=
'<li data-cover = "'
.
nap_category_image
(
$sub_category
->
term_id
)
.
'"><a class="'
.
$calss
.
'" href="#cat'
.
$sub_category
->
term_id
.
'">'
.
$subcat_name
[
1
]
.
'</a></li>'
;
$menu
.=
'<li data-cover = "'
.
nap_category_image
(
$sub_category
->
term_id
)
.
'"><a class="'
.
$calss
.
'" href="#cat'
.
$sub_category
->
term_id
.
'">'
.
$subcat_name
[
1
]
.
'</a></li>'
;
}
}
}
}
...
@@ -349,8 +321,30 @@ function nap_variation_url($variationID) {
...
@@ -349,8 +321,30 @@ function nap_variation_url($variationID) {
$couleur
=
$variable_product
->
get_attribute
(
'couleur'
);
$couleur
=
$variable_product
->
get_attribute
(
'couleur'
);
$format
=
$variable_product
->
get_attribute
(
'format'
);
$format
=
$variable_product
->
get_attribute
(
'format'
);
$url
=
'?attribute_couleur='
.
trim
(
$couleur
)
.
'&attribute_format='
.
trim
(
$format
);
$url
=
'?attribute_couleur='
.
$couleur
.
'&attribute_format='
.
$format
.
'&variation_id='
.
$variationID
;
return
preg_replace
(
'/\s+/'
,
''
,
$url
);
return
preg_replace
(
'/\s+/'
,
''
,
$url
);
}
function
nap_variation_color
(
$variationID
)
{
$variable_product
=
wc_get_product
(
$variationID
);
$term
=
get_term_by
(
'name'
,
$variable_product
->
get_attribute
(
'couleur'
),
'pa_couleur'
);
$termID
=
$term
->
term_id
;
$color
=
get_field
(
'couleurs'
,
'pa_couleur_'
.
$termID
);
return
$color
;
}
function
nap_distinct_color_variations
(
$variations
)
{
$var_colors
=
array
();
foreach
(
$variations
as
$variation
)
:
$variation_ID
=
$variation
[
'variation_id'
];
$color
=
nap_variation_color
(
$variation_ID
);
if
(
!
in_array
(
$color
,
$var_colors
))
:
$var_colors
[
$variation_ID
]
=
$color
;
endif
;
endforeach
;
return
$var_colors
;
}
}
function
nap_get_item
(
$post_ID
,
$args
=
null
,
$current_page
=
''
,
$options
=
null
)
{
function
nap_get_item
(
$post_ID
,
$args
=
null
,
$current_page
=
''
,
$options
=
null
)
{
...
@@ -381,13 +375,10 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
...
@@ -381,13 +375,10 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
$variations
=
get_posts
(
$args
);
$variations
=
get_posts
(
$args
);
$temp_colors
=
array
();
$temp_colors
=
array
();
foreach
(
$variations
as
$key
=>
$value
)
{
foreach
(
$variations
as
$key
=>
$value
)
{
$variable_product
=
wc_get_product
(
$value
->
ID
);
$color
=
nap_variation_color
(
$value
->
ID
);
$term
=
get_term_by
(
'name'
,
$variable_product
->
get_attribute
(
'couleur'
),
'pa_couleur'
);
if
(
!
in_array
(
$color
,
$temp_colors
))
{
$termID
=
$term
->
term_id
;
$color
=
get_field
(
'couleurs'
,
'pa_couleur_'
.
$termID
);
if
(
!
in_array
(
$color
,
$temp_colors
)){
$temp_colors
[]
=
$color
;
$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
,
'smal
l'
)
.
'" data-color = "'
.
$color
.
'"></li> '
;
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
nap_variation_url
(
$value
->
ID
)
.
'" data-image = "'
.
get_the_post_thumbnail_url
(
$value
->
ID
,
'thumbnai
l'
)
.
'" data-color = "'
.
$color
.
'"></li> '
;
}
}
}
}
$nap_article
.=
'</ul>'
;
$nap_article
.=
'</ul>'
;
...
@@ -398,3 +389,5 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
...
@@ -398,3 +389,5 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
return
$nap_article
;
return
$nap_article
;
}
}
remove_action
(
'woocommerce_after_single_product_summary'
,
'woocommerce_output_related_products'
,
20
);
wp-content/themes/nap/woocommerce/archive-product.php
View file @
8b1c16df
...
@@ -132,9 +132,11 @@ $child_category = get_terms('product_cat', array('parent'=>$cateID, 'child_of' =
...
@@ -132,9 +132,11 @@ $child_category = get_terms('product_cat', array('parent'=>$cateID, 'child_of' =
$args
=
array
(
'post_type'
=>
'product'
,
'stock'
=>
1
,
'posts_per_page'
=>
-
1
,
'product_cat'
=>
$value
->
name
);
$args
=
array
(
'post_type'
=>
'product'
,
'stock'
=>
1
,
'posts_per_page'
=>
-
1
,
'product_cat'
=>
$value
->
name
);
$naps_posts
=
new
WP_Query
(
$args
);
$naps_posts
=
new
WP_Query
(
$args
);
$options
=
array
();
$options
=
array
();
$options
[
'size'
]
=
'small'
;
while
(
$naps_posts
->
have_posts
())
:
$naps_posts
->
the_post
();
while
(
$naps_posts
->
have_posts
())
:
$naps_posts
->
the_post
();
$id
=
get_the_ID
();
$id
=
get_the_ID
();
$options
[
'size'
]
=
(
get_field
(
'produit_affichage'
,
$id
))
?
get_field
(
'produit_affichage'
,
$id
)
:
'small'
;
$args
=
array
(
$args
=
array
(
'post_type'
=>
'product_variation'
,
'post_type'
=>
'product_variation'
,
'post_status'
=>
array
(
'private'
,
'publish'
),
'post_status'
=>
array
(
'private'
,
'publish'
),
...
...
wp-content/themes/nap/woocommerce/single-product.php
View file @
8b1c16df
This diff is collapsed.
Click to expand it.
wp-content/themes/nap/woocommerce/single-product/add-to-cart/variable.php
View file @
8b1c16df
This diff is collapsed.
Click to expand it.
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