Commit 02692434 authored by imac's avatar imac

[Update]Redmine - #644 : Add URL to product page

parent 349939a3
<?php wp_footer(); ?> <?php
$ext_ref = externe_referrer();
if($ext_ref) {
get_footer();
}else{
wp_footer();
}
?>
...@@ -599,39 +599,15 @@ function nap_save_general_proddata_custom_field( $post_id ) { ...@@ -599,39 +599,15 @@ function nap_save_general_proddata_custom_field( $post_id ) {
} }
//MS 2017-08-02 : Get referrer //MS 2017-08-02 : Get referrer
function externe_referrer( ) { function externe_referrer(){
$url = $_SERVER['HTTP_REFERER']; $url = $_SERVER['HTTP_REFERER'];
$postid = url_to_postid( $url ); $postid = url_to_postid( $url );
$ref = false; $ref = false;
$uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $uri = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$pageWasRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0'; $pageWasRefreshed = isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'max-age=0';
if($pageWasRefreshed ) { if($pageWasRefreshed || empty( $url) ) {
$postid = -1;
} else{
$postid = 0;
}
if ($postid < 0){
$ref = true; $ref = true;
} }
echo $postid;
if($pageWasRefreshed ) {
$postid = -1;
}
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) {
$product_cat_id = $term->term_id;
echo 'prod_eeeeee === '. $product_cat_id;
break;
return $ref ; return $ref ;
} }
}
<?php wp_head(); //get_header( 'shop' );?> <?php
$ext_ref = externe_referrer();
if($ext_ref) {
get_header();
}else{
wp_head();
}
?>
...@@ -24,15 +24,20 @@ global $product; ...@@ -24,15 +24,20 @@ global $product;
$id = get_the_ID(); $id = get_the_ID();
$parent_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' => 0,'fields' => 'ids' )); $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' => 'names' ));
//Get Bach URL
$ext_ref = externe_referrer();
if($ext_ref) {
$category_link = get_category_link($parent_cat[0]);
}else{
$category_link ="#";
}
do_action('woocommerce_before_add_to_cart_form'); do_action('woocommerce_before_add_to_cart_form');
?> ?>
<div id="product" class="clearfix"> <div id="product" class="clearfix">
<div class="product-images row animated"> <div class="product-images row animated">
<div class = "btn-wrapper row close-panel"> <div class = "btn-wrapper row close-panel">
<div class="pink-btn circle-btn"><a href="#"><span class = "abs-center backlink">Retour</span></a></div> <div class="pink-btn circle-btn"><a href="<?php echo $category_link ?>"><span class = "abs-center backlink">Retour</span></a></div>
</div> </div>
<div class="product-slides row"> <div class="product-slides row">
<div class="product-header"> <div class="product-header">
......
...@@ -26,9 +26,13 @@ $attribute_keys = array_keys($attributes); ...@@ -26,9 +26,13 @@ $attribute_keys = array_keys($attributes);
$parent_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' => 0,'fields' => 'ids' )); $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' => 'names' ));
$current_variationID = $_GET['variation_id']; $current_variationID = $_GET['variation_id'];
$ext_ref = externe_referrer();
if($ext_ref) {
$category_link = get_category_link($parent_cat[0]);
}else{
$category_link ="#";
}
if (!function_exists('print_attribute_radio')) { if (!function_exists('print_attribute_radio')) {
function print_attribute_radio($checked_value, $value, $label, $name, $index=0) { function print_attribute_radio($checked_value, $value, $label, $name, $index=0) {
...@@ -76,7 +80,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -76,7 +80,7 @@ do_action('woocommerce_before_add_to_cart_form');
<div id="product" class="clearfix"> <div id="product" class="clearfix">
<div class="product-images row animated"> <div class="product-images row animated">
<div class = "btn-wrapper row close-panel"> <div class = "btn-wrapper row close-panel">
<div class="pink-btn circle-btn"><a href="#"><span class = "abs-center backlink">Retour</span></a></div> <div class="pink-btn circle-btn"><a href="<?php echo $category_link ?>"><span class = "abs-center backlink">Retour</span></a></div>
</div> </div>
<div class="product-slides row"> <div class="product-slides row">
<div class="product-header"> <div class="product-header">
......
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