Viewing 8 replies - 1 through 8 (of 8 total)
  • I’ve got the same problem. I’ve added the code to modify the checkout woocommerce form (I want to remove some fields) but it doesn’t work.

    Could you please help me?

    Thanks a lot!

    Plugin Author Shea Bunge

    (@bungeshea)

    Keep in mind that Code Snippets only works with PHP code like you’d find in plugins. It doesn’t support raw HTML, CSS or JavaScript code (though there are ways to use them).

    If there’s an issue with code not working at all, generally it’s due to an issue in the code, not the plugin.

    Hi, I’m having the same problem, this is what I’m trying to get to work so that the breadcrumbs are not displayed on the main shop page of woocommerce.

    function my_woocommerce_custom_breadcrumbs() {
        if(is_shop()){
        remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
        }
    }
    add_filter('woocommerce_before_main_content','my_woocommerce_custom_breadcrumbs');

    I have a similar problem Shea. If I put this snippet in the plugin it doesn’t work, but if I put it into my theme’s functions.php it works fine.

    // Remove the shortcode that's automatically added before the content
    remove_filter( 'the_content', array( $post_series_manager, 'post_series_before' ) );
    Plugin Author Shea Bunge

    (@bungeshea)

    remove_filter() doesn’t work unless it is used correctly. It needs to be called after the filter has been added, but before it is called. The discrepancy between snippets and functions.php is because snippets run at an earlier hook than functions.php.

    Ladyfye:

    Your example doesn’t work because you’re trying to remove the filter in the filter hook itself. This is too late to remove the filter, as it is already running. Try changing the action the wrapper function is hooked to:

    function my_woocommerce_custom_breadcrumbs() {
        if ( is_shop() ) {
            remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
        }
    }
    add_action('woocommerce_loaded','my_woocommerce_custom_breadcrumbs');

    Terence:

    I think the issue here is that you’re trying to remove a filter before is has been registered. Try wrapping it in a later hook:

    add_action( 'init', function () {
    	global $post_series_manager;
    	// Remove the shortcode that's automatically added before the content
    	remove_filter( 'the_content', array( $post_series_manager, 'post_series_before' ) );
    } );

    It could also be an issue to do with access to the $post_series_manager variable.

    Hi! I’m trying to remove the “add to cart” button and display a different message for some customers (depending on badges through myCred) and have the normal add-to-cart option for others. I wrote this code and the plugin doesn’t object to any syntax, but it is not working. I really appreciate any help with this – thank you!!

    // this keeps the site from crashing if badges are disabled
    if (function_exists ('mycred_get_users_badges')){
    
      // get a variable for the badge of the user
      // *note: this only works if badges are only used for purchasing myCred and reset after each purchase!
      $this->load->database();
      class mycred;
      $mycred = new mycred;
    	$userPurchasedCultureCoinsQuestion = $this->$mycred->get_users_badges ($user_id);
    
      // get users' user ID
      	$user_id = pb_displayed_user_id();
    
      // text for purchase button if user has a badge/cannot purchase
    	if ( ($userPurchasedCultureCoinsQuestion == 0)) {
    	  function remove_loop_button(){
    		remove_action ('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
    		remove_action ('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
    		add_action ('init', 'remove_loop_button');
    		add_action (echo "sorry, you don't have enough earned Culture Coins to purchase");
    	  }
    
    }
    Plugin Author Shea Bunge

    (@bungeshea)

    mas6ce:

    My apologies, but I don’t really use Woocommerce (if that is what you’re using) and I wouldn’t know how to write code to work with it without a lot of research. Perhaps you’re better off posting this question on a forum specific to that plugin?

    Also, I would prefer it if you could start a new thread if you have an issue to do with Code Snippets instead of adding onto an existing thread.

    Okay thanks for replying!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘added code but not working’ is closed to new replies.