• Resolved yessoftmk

    (@yessoftmk)


    Hi, I need different text availability for one product category, I truyng:

    /* backorder text on single product page */
     
    function so_42345940_backorder_message( $text, $product ){
    	
      if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) {
    	  
    	  $text = __(' This product can be ordered, the delivery time is 12-22 days. ', 'your-textdomain' );
    	  
    	  $idcat =  wc_get_product_term_ids( wc_get_product()->get_id(), 'product_cat' );
    	  if(($idcat!="") && ($idcat[0] == 95)) 
    	   {
    		  $text = __(' This product can be ordered, the delivery time is 1-5 working days. ', 'your-textdomain' );
    	   }
        
      }
      return $text;
    }
    
    add_filter( 'woocommerce_get_availability_text', 'so_42345940_backorder_message', 10, 2 );

    When I test – all work, but after few days I see that my snippet are disabled because error – https://i.imgur.com/Utf9GWK.png
    There are probably some conditions occurring that cause the error… What could it be? I think I need to make additional conditions before executing the code.

    thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Shameem – a11n

    (@shameemreza)

    Hi @yessoftmk

    The issue seems to be related to the function wc_get_product() returning null. This could occur if the product does not exist or is being called outside of the product context.

    To prevent this, you can modify your function to check if a product exists before calling wc_get_product().

    Alternatively, you can use the WooCommerce Pre-Orders plugin. It allows customers to order products before they are available.

    I hope this helps! Please let us know how it goes or if you need further assistance.

    Thread Starter yessoftmk

    (@yessoftmk)

    super! Thanks for assist! I’ll try and write here

    Good luck

    Hi @yessoftmk,

    super! Thanks for assist! I’ll try and write here

    I’m glad to hear that you found our previous response helpful! We’re here to support you every step of the way.

    Once you’ve had a chance to implement the suggested changes or try out the WooCommerce Pre-Orders plugin, please don’t hesitate to share your results with us. If you encounter any further issues or have more questions, we’re more than happy to assist you.

    Good luck with your modifications, and we look forward to hearing from you soon.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘change text problem woocommerce_get_availability_text’ is closed to new replies.