Forum Replies Created

Viewing 15 replies - 16 through 30 (of 33 total)
  • Thread Starter mirwordpress

    (@mirwordpress)

    Hi @gabrielfuentes, thank you so much for your response. I actually managed to accomplish it yesterday by appending:

    '?product_tag=' . urlencode($atts["tag"])

    to the output string. I think I was overcomplicating a simple task – or Woocommerce already had the query string in place for product tags, i just needed to write it correctly.

    thanks again ??

    Thread Starter mirwordpress

    (@mirwordpress)

    hi @lepittenger & thank you for your reply.

    I didn’t write my question properly; to be exact, what i want is for when a customer clicks on the a category, depending on the page they are currently on ( there will be a parent category here ) only some products in that category are tagged for that category. so when they click that category ( while on a particular parent cat page ) I want only those tagged products to appear ( for that category ).

    i hope i explained that ok – see i have a custom function for those parent cat pages that only show categories that have products with those specific tagged products – im not sure whether i need to amend that function further for what i want now, or if i need to amend the function AND create custom taxonomy pages.

    • This reply was modified 3 years, 7 months ago by mirwordpress.
    Thread Starter mirwordpress

    (@mirwordpress)

    hi and thank you for your reply.

    I have had to work on other projects and returned to this yesterday. I have tried another way and succeeded but not sure if my code is correct. I have used echo within the function as i couldn’t figure out any way to have the url to appear. I know echo should not be used within a shortcode function.

    would you have any advice for my code attempt?
    i also need to change this so that ‘testingtag’ can be added within the shortcode parameters.

    function display_products()
    {
     ob_start();
    
     $args = array( 
                'post_type'      => 'product', 
                'posts_per_page' => -1, 
                'product_tag'    => array('testingtag'),
                );
     $loop = new WP_Query( $args );
     $product_count = $loop->post_count;
    
     
    
     if( $product_count > 0 ){
        ?><div class="woocommerce columns-4"><ul class="products columns-4"> <?php
        while ( $loop->have_posts() ) : $loop->the_post(); 
                global $product;
                global $post;
    
                $loop->post->ID;
                 
                $product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );   
                     
                
                $post_slug = $post->post_name;
                
                foreach( $product_cats as $collection ) {   
                    $test = ''; 
                    $single_cat = '';         
                    $test .= $collection->slug;
                    if ( $product_cats && ! is_wp_error ( $product_cats ) ){
                        $single_cat = array_shift( $product_cats );  ?>
                        
                        <li class="product-category product brand_cats"><div class="banner-box"><div class="banner-box__image"> <a href="<? bloginfo( 'url' ); ?>/product-category/<? $test; ?>/">
                        <?php glana_woo_subcategory_thumbnail( $collection);  ?>           
                       
                    </a></div>
                        <div class="banner-box__info"><a href="<?php bloginfo( 'url' ); ?>/product-category/<?php $test; ?>/"><h2 itemprop="name" class="woocommerce-loop-category__title"><span><?php $single_cat->name; ?></a></span></h2></li><?php }  
                     }           
        endwhile;
        ?></ul></div> <?php
     }else{
           ?><p>No product matching your criteria.</p><?php
     }
    
     $result =  ob_get_clean();
     return $result;
     }
     add_shortcode('display_products_by_tag', 'display_products');
    • This reply was modified 3 years, 7 months ago by mirwordpress.
    • This reply was modified 3 years, 7 months ago by mirwordpress.
    • This reply was modified 3 years, 7 months ago by mirwordpress.
    Thread Starter mirwordpress

    (@mirwordpress)

    thank you for your response.

    do you think i could achieve my goal somehow or have you any tips on how i could achieve it?

    Thread Starter mirwordpress

    (@mirwordpress)

    hi and thank you for your response. What i am trying to do is as follows: ( I think I may soon give up it seems impossible! )

    the website will cater for many different workplaces / industries but they will have the same categories in some cases, like ‘Hygiene’, ‘Workwear’. so for example, if a customer clicks on the workplace of Nursing Homes, the categories will show but when the category is clicked, like say they click ‘hygiene’; it will show the customer further categories and products for Hygiene that have products with the tag ‘nursing homes’. But the products will have many tags, like say ‘nursing homes’, ‘construction’, ‘kennels’ etc. So i want to show the customer relevant products for that workplace, and not show them something related like to construction hygiene, for example.

    I hope this explains it better but i think maybe i am trying to do something that has not been done before – or is impossible.

    pls let me know your thoughts.

    • This reply was modified 3 years, 8 months ago by mirwordpress.
    Thread Starter mirwordpress

    (@mirwordpress)

    hi tried order by, its not working. I think it’s some simple tweak that I can’t work out. this is probably something very complex. if you know of a way of achieving it through the wp_query class pls let me know. I am currently looking into this.

    Thread Starter mirwordpress

    (@mirwordpress)

    SELECT wp_terms.* 
        FROM wp_terms 
       INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id
             INNER JOIN wp_term_taxonomy AS ctax ON wp_terms.term_id = ctax.term_id
             INNER JOIN wp_term_relationships AS crel ON crel.term_taxonomy_id = ctax.term_taxonomy_id
    INNER JOIN wp_posts AS posts ON posts.ID = crel.object_id
    INNER JOIN wp_term_relationships AS trel ON posts.ID = trel.object_id
    INNER JOIN wp_term_taxonomy AS ttax ON trel.term_taxonomy_id = ttax.term_taxonomy_id
    INNER JOIN wp_terms AS tags ON ttax.term_id = tags.term_id
             WHERE ctax.taxonomy = 'product_cat'
    AND ttax.taxonomy = 'product_tag'
    AND posts.post_type = 'product'
    AND posts.post_status = 'publish'
    AND tags.term_id = '%d'
    GROUP BY wp_terms.term_id = 247

    this is my current query – it’s not working as i expectded.

    • This reply was modified 3 years, 8 months ago by mirwordpress.
    Thread Starter mirwordpress

    (@mirwordpress)

    thank you. My thinking was to try get the sql query working in php myadmin first and then compose it into the format required for the php function.

    i can’t seem to get the query to work.

    Thread Starter mirwordpress

    (@mirwordpress)

    thank you Joy. My question was a little muddled. I have re posted the question with my further attempts.

    Thread Starter mirwordpress

    (@mirwordpress)

    yes i get what you mean. i really would like it to work, it seems to simple but yet seems difficult to implement. could you advise on which hooks i could use, or if if you believe its not possible. thank you again

    Thread Starter mirwordpress

    (@mirwordpress)

    hi
    thank you for your reply.
    so if a product has alot of variations ( which means many thumbnails at the bottom of the main product image )
    i want it to be like a slider with arrows ( for the thumbnails )
    for now i have hidden the images after the 4th image using css nth child, but would prefer to have it as a slider/carousel.

    the website uses Elementor pro, and the single product page uses an elementor widget called product images to display product images.
    any help at all would be great – i have been hours trying to find a solution – even tried to implement javascript /jquery but im not too familar with js

    • This reply was modified 3 years, 11 months ago by mirwordpress.
    Thread Starter mirwordpress

    (@mirwordpress)

    Thank you.
    Are there any alternatives? I am using as a Elementor pro. My job purchased a theme but I may drop it eventually

    Thread Starter mirwordpress

    (@mirwordpress)

    Thanks Joy.

    Do you mean loading the bootstrap library may affect performance?

    Thread Starter mirwordpress

    (@mirwordpress)

    thanks for that link will check it out ??

    Thread Starter mirwordpress

    (@mirwordpress)

    thank you again.
    I was hoping to upload current versions of products as the current website is outdated and alot of products and their imagery are outdated.
    it would be interesting to know what experienced developers do in this case – where they have 1000s of products to upload. I did come across WP-CLI – have you ever used this or heard much about it?

    Otherwise, no other leads than to use the default woocommerce upload function..

Viewing 15 replies - 16 through 30 (of 33 total)