Space needed inbtween words "out of stock" & "in stock"

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Space needed inbtween words "out of stock" & "in stock"

This topic contains 13 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 weeks, 6 days ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #40572
    Stuart Joyce
    Stuart Joyce
    Participant

    A minor issue is that the term out of stock and in stock would look loads better with correct spacing between words. Please see screenshot image with no spacing between works that is what we have currently.

    Thanks

    • This topic was modified 1 month, 2 weeks ago by Stuart Joyce Stuart Joyce.
    #40584
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I’m afraid the screenshot was not uploaded, can you please try again?

    I assume you are reffering to the “_stock_status” custom field? The value of that field is set by WooCommerce, all the plugin does is prints the value. If you upload the screenshot I will check where exactly it is used, maybe there is something we can do about it.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40588
    Stuart Joyce
    Stuart Joyce
    Participant
    You cannot access this content.
    #40595
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay, then you could probably do a trick with custom CSS and a different HTML in the advanced field. Try this in the advanced content field:

    <span class="{_stock_status}"></span>

    This will apply a class name instead of the actual text. Now add this custom CSS somewhere (either in your theme settings or under here):

    span.instock::after {
       content: 'In Stock';
       color: green;
    }
    
    span.outofstock::after {
       content: 'Out of Stock';
       color: #ff6600;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40596
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Regarding the wrongly reported stock status – that is unfortunately not related to our plugin, the search only prints whatever is stored within that field.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40681
    Stuart Joyce
    Stuart Joyce
    Participant

    Hi

    That css fix did the trick and looks really good.

    Can you let me know how i can sort out the stock status issue as all our products are external stock items and are not marked as out of stock so very unsure how your plugin is finding a table that shows they are out of stock?

    Are you able to point me in the right direction to fix this? Is it maybe that your plugin does not work with external products?

    Kind regards

    Stuart

    #40694
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    You are welcome.

    The plugin only requests the “_stock_status” custom field and prints it’s value as instructed – the value is either “instock” or “outofstock”. Maybe on external products this is not controlled or is automatically set to “instock” by WooCommerce. I have not found any information regarding that in their documentation.

    I can only assume that the stock status is later changed during the execution via a hook, but not the actual value in the database.

    There is one more thing you can try, this custom code:

    1. Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter('asp_results', 'asp_show_stock_status');
    function asp_show_stock_status($results) {
    	foreach($results as $k=>&$r){
            if ( $r->post_type == 'product' && class_exists('WC_Product') ) {
    			$p = new WC_Product();
    			$r->content .= '<span class="'.$p->get_stock_status().'"></span>';
    		}
        }
        return $results;
    }

    2. Remove this <span class="{_stock_status}"></span> from the advasced content fields, the custom code will handle it.

    3. Keep the custom CSS suggested.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40705
    Stuart Joyce
    Stuart Joyce
    Participant

    Hi Ernest.

    Thanks for your reply. It almost works!

    I have the opposite issue now. I have all products showing in stock when some are not in stock.

    So to confirm how I use woocommerce i use external affiliate products for in-stock items and when they go out of stock or are no longer available I change them to a simple product and change the stock status to out of stock in the manage stock section.

    It would be good for you to get to the bottom of this as I can not be the only one who uses woo-commerce with affiliate external products.

    Thanks

    Kind regards

    Stuart

    #40707
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I may have made a mistake in the previous code, the ID parameter was missing, please try:

    add_filter('asp_results', 'asp_show_stock_status');
    function asp_show_stock_status($results) {
    	foreach($results as $k=>&$r){
            if ( $r->post_type == 'product' && class_exists('WC_Product') ) {
    			$p = new WC_Product( $r->id );
    			$r->content .= '<span class="'.$p->get_stock_status().'"></span>';
    		}
        }
        return $results;
    }

    This should work, as it requests the stock status from WooCommerce directly.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40766
    Stuart Joyce
    Stuart Joyce
    Participant
    You cannot access this content.
    #40769
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    In the video, when you opened the product editor – there was no stock information for the product. Also, when you opened the product page I could not see any information about the stock status either. That very likely means, that WooCommerce has no knowledge of the stock status of the external product, so it simply returns it is out of stock.
    In order to have the stock status available, it must be requested from somewhere. These products are external so the external store handles the stock, which I guess is not connected via API or any other means to WooCommerce to report and to store the stock status locally.

    Simply put, the reason the wrong stock status is shown, that this information is simply not available for the shop.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40780
    Stuart Joyce
    Stuart Joyce
    Participant

    Hi

    That’s a shame. So it looks like your plugin is not compatible with external products if you wish to have the stock status shown.

    No prob, thanks for your time,

    Kind regrds

    #40782
    Stuart Joyce
    Stuart Joyce
    Participant
    You cannot access this content.
    #40785
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Google is a global search engine, and the shop sends the vendor data to google to get the stock status – it does not appear from nowehere. There is an API on the google search console, where the stock data can be fetched from either the OpenGraph protocol or via other API.

    The stock information is not available on your local shop, so there is no way to access that. Ajax search pro would have to crawl the destination URLs to fetch Open Graph information – which is not what it’s designed for, it is a local search engine for the local database, and the stock status is not available, even Woocommerce can’t tell if the product is in stock.

    Google has the ability to crawl external sites – even if we implemented such feature, that would very quickly cause huge problems. Crawling external sites requires access permissions, very powerful servers, AI interface for data organization etc.. Your website would start slowing down at first, then the database would start growing uncontrollably, not to mention the external site firewalls – your server would very likely end up on a blacklist too.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.