0

I am trying to insert this meta information into the cart and checkout page for woocommerce. It will hide a specific plugin on those pages. However i know if i edit the plugin files for woocommerce it will be overwritten on woocommerce update.

How would i do that correctly? Jquery? Or even function.php function?

if (wc_get_page_id( 'cart' ) == get_the_ID()) {
  <meta name="yo:active" content="false">
}

or

if !is_page(array('cart', 'checkout')) {
  $('#yoHolder').attr("style", "display: none !important");
}

i tried this too to achieve same outcome of hiding it but didnt work.

Thanks for any help!

7
  • Just curious, what plugin are you wanting to disable on that page? A lot of plugins (if done right) will enqueue their scripts and styles, so you could potentially unenqueue them with the wp_enqueue_scripts action.
    – Ian
    Mar 20, 2017 at 21:53
  • Its called Yo. and the <meta> snippet they provided is whats in my first code snippet example.
    – Patrick
    Mar 20, 2017 at 22:03
  • In its current form this is just a bad question. what is it Yo, what does it insert, how does it does it and what part of it you want to removed.It is hard to answer the question without this info. Please edit the question so that even people that are not familiar with it will be able to understand the issue you are facing Mar 21, 2017 at 3:21
  • 1
    You literally dont need to know ANYTHING about yo to answer my question. Note the person said they were "just curious" so i answered them. So your comment is bad. Not my post - which i offered cred for.
    – Patrick
    Mar 21, 2017 at 5:46
  • your question was both bad and off-topic, but guess it is up to you to learn from comments you get or not Mar 21, 2017 at 8:44

2 Answers 2

3
+50

If your goal is to put it in the <head>IM INSIDE THE HEAD</head> tag than just put it inside the head tag in the theme_header.php or header.php of your theme – if it's not a child theme.

Place this snippet of code directly above the closing </head> tag in your header.php file.

<?php
if ( is_checkout() || is_cart() ) {
  // Add meta tag here
echo '<meta name="yo:active" content="false">';
}
?>

Should work fine for you.

2
  • Nice! I am glad it worked for you. When do I get my rep points? haha Mar 21, 2017 at 8:23
  • 1
    I tried but it says i have to wait 12 hours before awarding it.
    – Patrick
    Mar 21, 2017 at 8:25
1

Add the code to the file functions.php

/**
 * add data in cart 
 * 
 */
function add_custom_data_in_cart() {
   echo '<meta name="yo:active" content="false">'; 
}

add_action('woocommerce_cart_is_empty', 'add_custom_data_in_cart');

/**
 * add data in checkout 
 * 
 */
function add_custom_data_in_checkout() {
   echo '<meta name="yo:active" content="false">'; 
}

add_action('woocommerce_before_checkout_form', 'add_custom_data_in_checkout');
2
  • This solution does not suit you? If not, tell me what's wrong, I'll correct it.
    – TrubinE
    Mar 21, 2017 at 7:33
  • No it wasnt working for some reason. I sent your code to the plugin developer but he hasnt replied yet. The other solution recently posted worked for us. I do appreciate your early attention to my post. Gave u an up vote.
    – Patrick
    Mar 21, 2017 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.