Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Hello, I am looking for some help with modifying my product page using WordPress

  • SOLVED

Hello,

I am looking for some help with modifying my product page using wordpress hooks and functions.php. I am looking to do two things

I would like to hook this code to display below the add to cart button with following condiitons:

If product in category "sneakers" output this code
<p style="font-size: small;color: #999999;line-height:1em;text-align:center;">Return Policy: Returns accepted if product does not fit, buyer pays return shipping fee</p>
<img class="aligncenter" style="padding-top:4px;" src="https://staging11.brightledshoes.com/wp-content/uploads/2018/07/asseenine-1.png" alt="led shoes guarantee"/></br>

else output this code
<img class="aligncenter" style="padding-top:4px;" src="https://staging11.brightledshoes.com/wp-content/uploads/2018/07/asseenine-1.png" alt="led shoes guarantee"/></br>

I already have a hook in my functions.php that I think is not letting me add more hooks below add to cart. I have added my functions file below and I am using the storefront theme.

Thank you

<?php

/**
* Storefront automatically loads the core CSS even if using a child theme as it is more efficient
* than @importing it in the child theme style.css file.
*
* Uncomment the line below if you'd like to disable the Storefront Core CSS.
*
* If you don't plan to dequeue the Storefront Core CSS you can remove the subsequent line and as well
* as the sf_child_theme_dequeue_style() function declaration.
*/
//add_action( 'wp_enqueue_scripts', 'sf_child_theme_dequeue_style', 999 );

/**
* Dequeue the Storefront Parent theme core CSS
*/
function sf_child_theme_dequeue_style() {
wp_dequeue_style( 'storefront-style' );
wp_dequeue_style( 'storefront-woocommerce-style' );
}

/**
* Note: DO NOT! alter or remove the code above this text and only add your custom PHP functions below this text.
*/
add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

/*** CATEGORY PAGE ***///
// allow html in category and taxonomy descriptions
remove_filter( 'pre_term_description', 'wp_filter_kses' );
remove_filter( 'pre_link_description', 'wp_filter_kses' );
remove_filter( 'pre_link_notes', 'wp_filter_kses' );
remove_filter( 'term_description', 'wp_kses_data' );
remove_action( 'woocommerce_before_shop_loop', 'storefront_woocommerce_pagination', 30 );


///*** PRODUCT PAGE *///
add_action( 'woocommerce_review_meta', 'add_content_after_review_func' );
function add_content_after_review_func() {
// Echo content.
echo '<a href="#" class="button"><span class="glyphicon glyphicon-thumbs-up"></span><i class="fa fa-thumbs-up" aria-hidden="true"></i> VERIFIED BUYER</a>';
}

add_filter( 'woocommerce_product_tabs', 'reordered_tabs', 98 );
function reordered_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5;
$tabs['description']['priority'] = 10;


return $tabs;
}
/** Remove product data tabs **/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] ); // Remove the additional information tab

return $tabs;
}
/** Shipping and Returns product tab **/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {

// Adds the new tab

$tabs['shipreturns'] = array(
'title' => __( 'Shipping and Returns', 'woocommerce' ),
'priority' => 15,
'callback' => 'woo_new_product_tab_content'
);

return $tabs;

}
function woo_new_product_tab_content() {

// The new tab content

echo '<h2>Shipping Information</h2>';
echo '<p>
U.S.A. Shipping: All orders over $75 qualify for free shipping! For all orders under $75 shipping fee is $5.99
<br>
Shipping Time: 4-12 days
<br>
Order Processing: 24-72 hours
<br>
We use DHL, UPS, and USPS for delivery. In the event that your item is out of stock in our USA warehouse we will ship from our international warehouses in U.K. or China. In this case please allow 2 days of extra processing time for your order.
<br>
<br>
International Shipping: Canada, Australia, United Kingdom, Canada, Israel, Norway, France, Brazil, Spain, Netherlands, Denmark, Germany, Mexico, South Africa, Sweden
<br>
International Shipping cost: $6.99.
<br>
Shipping Time: 8-15 days
<br>
Order Processing: 24-72 hours
<br>
Important Note: Some customers may have to pay a customs fee on their products upon arrival of their country. This isn’t exclusively a shipping issue but an international shipping one. We are not responsible for any fee you my incur.
</p>';
echo '<h2>Returns and Exchanges</h2>';
echo '<p>We provide hassle free easy returns. You have 7 days from the day you received your items to review, and if necessary, request an exchange. Your package must not be post marked any later than 7 days from the delivery date.
Using our returns/exchange form you can quickly request a return. It is your responsibility to return the item(s) to Bright LED Shoes and pay for shipping cost. After inspection we will send you an exchange. All sales are final and we do not refund sale or clearance items. <a href="https://staging12.brightledshoes.com/return-policy/">Click here to view full return policy</a></p>';

}
/** Buyer Guarantee tab **/
function woo_new_product_tab_warranty( $tabs ) {

// Adds the new tab

$tabs['warranty'] = array(
'title' => __( 'Buyer Guarantee', 'woocommerce' ),
'priority' => 30,
'callback' => 'woo_new_product_tab_warranty_content'
);

return $tabs;

}
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab_warranty' );
function woo_new_product_tab_warranty_content() {

// The new tab content

echo '<h2>Safe and secure purchase</h2>';
echo '<p>Bright LED Shoes is committed to providing our customers with high quality products. Shop safely and secure knowing all of our light up shoes batteries come backed by a 30 day warranty. Warranty is effective on the date of purchase.Our warranty covers the battery that powers our led shoes. If your lights are no longer working you can submit a return request using our form. You will then be sent instructions to test your shoes to confirm the battery is the cause of the issue. If we determine that is the case we will send you a replacement battery which you can easily insert into your shoes.</p>';
}

function my_text_based_on_geolocation(){

// Geolocation must be enabled @ Woo Settings

$location = WC_Geolocation::geolocate_ip();
$country = $location['country'];

// Lets use the country to e.g. echo greetings

switch ($country) {
case "US":
$hello = '
<div class="shipsec"><span style="font-size: medium;color: #999999;">Shipping:  Fast Shipping to United States</span> <img class="" src="https://staging12.brightledshoes.com/wp-content/uploads/2018/08/shipping.jpg" alt="" width="70" height="18" />
<span style="color: #999999;">                     Estimated Delivery Time: 7-12 days</span></div>';
break;
case "CA":
$hello = '
<div class="shipsec"><span style="font-size: medium;color: #999999;">Shipping:  Fast Shipping to Canada</span> <img class="" src="https://staging12.brightledshoes.com/wp-content/uploads/2018/08/capost.png" alt="" width="70" height="16" />
<span style="color: #999999;">                   Estimated Delivery Time:8-15 days</span></div>';
break;
case "UK":
$hello = '
<div class="shipsec"><span style="font-size: medium;color: #999999;">Shipping:  Fast Shipping to United Kingdom</span> <img class="" src="https://staging12.brightledshoes.com/wp-content/uploads/2018/08/rmail.png" alt="" width="70" height="17" />
<span style="color: #999999;">                   Estimated Delivery Time:8-15 days</span></div>';
break;
case "AU":
$hello = '
<div class="shipsec"><span style="font-size: medium;color: #999999;">Shipping:  Fast Shipping to Australia</span> <img class="" src="https://staging12.brightledshoes.com/wp-content/uploads/2018/08/aupost.png" alt="" width="53" height="18" />
<span style="color: #999999;">                   Estimated Delivery Time:8-15 days</span></div>';
break;
default:
$hello = '
<div class="shipsec"><span style="font-size: medium;color: #999999;">Shipping:  Fast Shipping
<span style="color: #999999;">                   Estimated Delivery Time:8-15 days</span></div>';
}

echo $hello;
}

add_action( 'echo_geolocation_text', 'my_text_based_on_geolocation' );

add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart_button_func' );

function add_content_after_addtocart_button_func() {

// Echo content.

echo do_action( 'echo_geolocation_text' );

}

Answers (3)

2018-08-28

Navjot Singh answers:

Try adding this code into your existing add_content_after_addtocart_button_func()

if ( is_product() && has_term( 'sneakers', 'product_cat' ) ) {
echo '<p style="font-size: small;color: #999999;line-height:1em;text-align:center;">Return Policy: Returns accepted if product does not fit, buyer pays return shipping fee</p>
<img class="aligncenter" style="padding-top:4px;" src="https://staging11.brightledshoes.com/wp-content/uploads/2018/07/asseenine-1.png" alt="led shoes guarantee"/></br>';
}
else echo '<img class="aligncenter" style="padding-top:4px;" src="https://staging11.brightledshoes.com/wp-content/uploads/2018/07/asseenine-1.png" alt="led shoes guarantee"/></br>';

2018-08-28

Mohamed Ahmed answers:

Hello George,

Could you send me your site url and wp admin login info to my email
[email protected]
I knew the concept of your needs and I have the solution

2018-08-28

Arnav Joy answers:

Please show me your site.