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
470f856a
Commit
470f856a
authored
Aug 16, 2017
by
Nahla Shiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajouter des images ambiance dans une fiche produit
parent
733aa4a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
73 deletions
+64
-73
functions.php
wp-content/themes/nap/functions.php
+1
-1
simple.php
...mes/nap/woocommerce/single-product/add-to-cart/simple.php
+42
-53
variable.php
...s/nap/woocommerce/single-product/add-to-cart/variable.php
+21
-19
No files found.
wp-content/themes/nap/functions.php
View file @
470f856a
...
...
@@ -471,7 +471,7 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
}
else
{
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
'" data-image = "'
.
nap_image_resize
(
get_the_post_thumbnail_url
(
$value
->
ID
),
'200'
)
.
'"></li> '
;
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
'" data-image = "'
.
nap_image_resize
(
get_the_post_thumbnail_url
(
$value
->
ID
),
'200'
)
.
'"
data-color = "'
.
get_post_thumbnail_id
(
$post_ID
)
.
'" data-format = ""
></li> '
;
}
$nap_article
.=
'</ul>'
;
endif
;
...
...
wp-content/themes/nap/woocommerce/single-product/add-to-cart/simple.php
View file @
470f856a
<?php
//print_r($_GET);
/**
* Variable product add to cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/variable.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 3.0.0
*/
// A factoriser avec variable.php
if
(
!
defined
(
'ABSPATH'
))
{
exit
;
}
global
$product
;
$ambiance_product
=
$product
->
get_gallery_attachment_ids
();
$id
=
get_the_ID
();
$parent_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
0
,
'fields'
=>
'ids'
));
$sub_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
$parent_cat
[
0
],
'fields'
=>
'names'
));
//Get Back URL
$parent_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
0
,
'fields'
=>
'ids'
));
$sub_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
$parent_cat
[
0
],
'fields'
=>
'all'
));
$ext_ref
=
externe_referrer
();
$class_back
=
""
;
if
(
$ext_ref
)
{
$category_link
=
get_category_link
(
$parent_cat
[
0
]);
$class_back
=
"ext-link"
;
}
else
{
$category_link
=
"#"
;
if
(
$ext_ref
)
{
$category_link
=
get_category_link
(
$parent_cat
[
0
]);
$class_back
=
"ext-link"
;
}
else
{
$category_link
=
"#"
;
}
do_action
(
'woocommerce_before_add_to_cart_form'
);
?>
<ul
class=
"hidden"
>
<li
class=
"color-list selected "
data-color=
"
<?php
echo
get_post_thumbnail_id
(
$ID
)
?>
"
></li>
</ul>
<div
id=
"product"
class=
"clearfix"
>
<div
class=
"product-images row animated"
>
<div
class =
"btn-wrapper row close-panel
<?php
echo
$class_back
?>
"
>
...
...
@@ -43,7 +31,7 @@ do_action('woocommerce_before_add_to_cart_form');
</div>
<div
class=
"product-slides row"
>
<div
class=
"product-header"
>
<h2
class=
"crete -italic font-small"
>
<?php
echo
$sub_cat
[
0
]
?>
</h2>
<h2
class=
"crete -italic font-small"
>
<?php
echo
$sub_cat
[
0
]
->
name
?>
</h2>
<h3
class=
"crete"
>
<?php
the_title
();
?>
</h3>
</div>
<div
class=
"slides-wrapper center"
>
...
...
@@ -58,7 +46,7 @@ do_action('woocommerce_before_add_to_cart_form');
<div
id=
"slides"
>
<?php
?>
<div
style=
"background-image:url('
<?php
echo
get_the_post_thumbnail_url
(
$ID
,
'medium'
)
?>
')"
class=
"image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle"
data-slick-index =
"1"
>
<div
style=
"background-image:url('
<?php
echo
get_the_post_thumbnail_url
(
$ID
,
'medium'
)
?>
')"
class=
"image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle"
data-
color =
"
<?php
echo
get_post_thumbnail_id
(
$ID
)
?>
"
data-
slick-index =
"1"
>
<a
href=
"
<?php
echo
get_the_post_thumbnail_url
(
$ID
,
'full'
)
?>
"
>
<!--<img src="
<?php
echo
get_the_post_thumbnail_url
(
$ID
,
'medium'
)
?>
" alt="" />-->
</a>
...
...
@@ -66,24 +54,27 @@ do_action('woocommerce_before_add_to_cart_form');
<?php
/* if (get_field('images_ambiance', 'product_cat_' . $subcat_iD)):
$ambiance = array();
while (has_sub_field('images_ambiance', 'product_cat_' . $subcat_iD)) :
$image_amb = get_sub_field('img_ab');
$ambiance [] = $image_amb;
$attachment = wp_get_attachment_image_src($image_amb, 'medium');
$hd = wp_get_attachment_image_src($image_amb, 'full');
?>
<div style="background-image:url('<?php echo $attachment[0]; ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-slick-index = "1">
<a href="<?php echo $hd[0]; ?>">
<!--<img src="<?php echo $attachment[0]; ?>" alt="" />-->
</a>
</div>
<?php
endwhile;
endif; */
?>
if
(
get_field
(
'images_ambiance'
,
'product_cat_'
.
$sub_cat
[
0
]
->
term_id
))
:
if
(
!
empty
(
$ambiance_product
))
{
$ambiance
=
$ambiance_product
;
}
else
{
$ambiance
=
array
();
}
while
(
has_sub_field
(
'images_ambiance'
,
'product_cat_'
.
$sub_cat
[
0
]
->
term_id
))
:
$image_amb
=
get_sub_field
(
'img_ab'
);
$ambiance
[]
=
$image_amb
;
endwhile
;
endif
;
foreach
(
$ambiance
as
$key
=>
$value
)
:
$attachment
=
wp_get_attachment_image_src
(
$value
,
'medium'
);
$hd
=
wp_get_attachment_image_src
(
$value
,
'full'
);
?>
<div
style=
"background-image:url('
<?php
echo
$attachment
[
0
];
?>
')"
class=
"image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle"
data-color =
"
<?php
echo
$value
;
?>
"
data-slick-index =
"1"
>
<a
href=
"
<?php
echo
$hd
[
0
];
?>
"
>
</a>
</div>
<?php
endforeach
;
?>
</div>
</div>
...
...
@@ -92,7 +83,7 @@ do_action('woocommerce_before_add_to_cart_form');
<span
class=
"close-btn"
></span>
<article
class =
"row"
data-color =
""
>
<article
class =
"row"
data-color =
"
<?php
echo
get_post_thumbnail_id
(
$ID
)
?>
"
>
<a
href=
"
<?php
echo
get_the_post_thumbnail_url
(
$ID
,
'full'
)
?>
"
></a>
<figure>
<img
src=
"
<?php
echo
get_the_post_thumbnail_url
(
$ID
,
'medium'
)
?>
"
alt=
""
title=
""
>
...
...
@@ -105,7 +96,7 @@ do_action('woocommerce_before_add_to_cart_form');
$hd
=
wp_get_attachment_image_src
(
$value
,
'full'
);
?>
<article
class =
"row"
data-color =
"
red
"
>
<article
class =
"row"
data-color =
"
<?php
echo
$value
;
?>
"
>
<a
class =
"download-btn"
href=
"
<?php
echo
$hd
[
0
];
?>
"
download
></a>
<figure>
<img
src=
"
<?php
echo
$attachment
[
0
];
?>
"
alt=
""
title=
""
>
...
...
@@ -125,17 +116,17 @@ do_action('woocommerce_before_add_to_cart_form');
<?php
$formats
=
explode
(
','
,
nap_variation_format
(
$id
));
?>
<div
class=
"product-details full-height row right transition"
>
<div
class=
"product-info row center right border-l"
>
<div
class=
"info-content"
>
<?php
$formats
=
explode
(
','
,
nap_variation_format
(
$id
));
?>
<h2
class =
"crete font-small"
>
<?php
echo
$sub_cat
[
0
]
?>
</h2>
<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
$formats
[
0
];
?>
</span>
<span
class=
"info-color"
>
<?php
echo
$_GET
[
'attribute_couleur'
]
?>
</span></h3>
<div
class=
"details font-small"
>
<p
class=
"info-format-txt"
>
<?php
echo
$formats
[
0
];
?>
</p>
<p
class=
"pq"
>
<?php
echo
do_shortcode
(
get_the_excerpt
());
?>
</p>
<p
class=
"pq"
>
<?php
echo
do_shortcode
(
get_the_excerpt
());
?>
</p>
</div>
<div
class=
"price"
>
<span
class=
"crete"
>
<?php
echo
$price
=
get_post_meta
(
get_the_ID
(),
'_regular_price'
,
true
);
?>
€ ht
</span>
...
...
@@ -187,8 +178,6 @@ do_action('woocommerce_before_add_to_cart_form');
</figure>
<h3
class =
"font-small"
>
Pailles
</h3>
</article>
</div>
</div>
</div>
wp-content/themes/nap/woocommerce/single-product/add-to-cart/variable.php
View file @
470f856a
<?php
//print_r($_GET);
/**
* Variable product add to cart
*
...
...
@@ -21,11 +20,12 @@ if (!defined('ABSPATH')) {
}
global
$product
;
$ambiance_product
=
$product
->
get_gallery_attachment_ids
();
$attribute_keys
=
array_keys
(
$attributes
);
$parent_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
0
,
'fields'
=>
'ids'
));
$sub_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
$parent_cat
[
0
],
'fields'
=>
'
names
'
));
$sub_cat
=
wp_get_post_terms
(
$product
->
get_id
(),
'product_cat'
,
array
(
'parent'
=>
$parent_cat
[
0
],
'fields'
=>
'
all
'
));
$current_variationID
=
$_GET
[
'variation_id'
];
$ext_ref
=
externe_referrer
();
$class_back
=
""
;
...
...
@@ -84,7 +84,7 @@ do_action('woocommerce_before_add_to_cart_form');
</div>
<div
class=
"product-slides row"
>
<div
class=
"product-header"
>
<h2
class=
"crete -italic font-small"
>
<?php
echo
$sub_cat
[
0
];
?>
</h2>
<h2
class=
"crete -italic font-small"
>
<?php
echo
$sub_cat
[
0
]
->
name
;
?>
</h2>
<h3
class=
"crete"
>
<?php
the_title
();
?>
</h3>
</div>
<div
class=
"slides-wrapper center"
>
...
...
@@ -112,25 +112,27 @@ do_action('woocommerce_before_add_to_cart_form');
endforeach
;
?>
<?php
if
(
get_field
(
'images_ambiance'
,
'product_cat_'
.
$subcat_iD
))
:
$ambiance
=
array
();
while
(
has_sub_field
(
'images_ambiance'
,
'product_cat_'
.
$subcat_iD
))
:
<?php
if
(
get_field
(
'images_ambiance'
,
'product_cat_'
.
$sub_cat
[
0
]
->
term_id
))
:
if
(
!
empty
(
$ambiance_product
))
{
$ambiance
=
$ambiance_product
;
}
else
{
$ambiance
=
array
();
}
while
(
has_sub_field
(
'images_ambiance'
,
'product_cat_'
.
$sub_cat
[
0
]
->
term_id
))
:
$image_amb
=
get_sub_field
(
'img_ab'
);
$ambiance
[]
=
$image_amb
;
$attachment
=
wp_get_attachment_image_src
(
$image_amb
,
'medium'
);
$hd
=
wp_get_attachment_image_src
(
$image_amb
,
'full'
);
?>
<div
style=
"background-image:url('
<?php
echo
$attachment
[
0
];
?>
')"
class=
"image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle"
data-color =
"
<?php
echo
$color
?>
"
data-slick-index =
"1"
>
<a
href=
"
<?php
echo
$hd
[
0
];
?>
"
>
<!--<img src="
<?php
echo
$attachment
[
0
];
?>
" alt="" />-->
</a>
</div>
<?php
endwhile
;
endif
;
?>
foreach
(
$ambiance
as
$key
=>
$value
)
:
$attachment
=
wp_get_attachment_image_src
(
$value
,
'medium'
);
$hd
=
wp_get_attachment_image_src
(
$value
,
'full'
);
?>
<div
style=
"background-image:url('
<?php
echo
$attachment
[
0
];
?>
')"
class=
"image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle"
data-color =
"
<?php
echo
$value
;
?>
"
data-slick-index =
"1"
>
<a
href=
"
<?php
echo
$hd
[
0
];
?>
"
>
</a>
</div>
<?php
endforeach
;
?>
</div>
</div>
...
...
@@ -153,7 +155,7 @@ do_action('woocommerce_before_add_to_cart_form');
$hd
=
wp_get_attachment_image_src
(
$value
,
'full'
);
?>
<article
class =
"row"
data-color =
"
red
"
>
<article
class =
"row"
data-color =
"
<?php
echo
$value
;
?>
"
>
<a
class =
"download-btn"
href=
"
<?php
echo
$hd
[
0
];
?>
"
download
></a>
<figure>
<img
src=
"
<?php
echo
$attachment
[
0
];
?>
"
alt=
""
title=
""
>
...
...
@@ -249,7 +251,7 @@ do_action('woocommerce_before_add_to_cart_form');
<div
class=
"product-info row center left border-l"
>
<div
class=
"info-content"
>
<h2
class =
"crete font-small"
>
<?php
echo
$sub_cat
[
0
];
?>
</h2>
<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
$_GET
[
'attribute_format'
]
?>
</span>
<span
class=
"info-color"
>
<?php
echo
$_GET
[
'attribute_couleur'
]
?>
</span></h3>
<div
class=
"details font-small"
>
<p
class=
"info-format-txt"
>
<?php
echo
$_GET
[
'attribute_format'
]
?>
</p>
...
...
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