Forum Replies Created

Viewing 15 replies - 1 through 15 (of 23 total)
  • Thread Starter David

    (@topsquirrel)

    Thanks,

    I’ve now successfully passed custom data through in the way I was hoping to following the approach described in the link.

    https://wisdmlabs.com/blog/add-custom-data-woocommerce-order-2/

    Thread Starter David

    (@topsquirrel)

    Thanks Andy,
    It’s not what I’m looking for but thanks ??

    Thread Starter David

    (@topsquirrel)

    p.s.
    I’m thinking this approach might help me…
    https://wisdmlabs.com/blog/add-custom-data-woocommerce-order-2/

    Thread Starter David

    (@topsquirrel)

    Hi Andy,
    Just a nudge @slash1andy if there is anything you can think of that might help?
    Thanks
    David

    Thread Starter David

    (@topsquirrel)

    Hi,

    Thanks for coming back to me. That sounds like a route that might work.

    The problem I’ve got is that there are lots of historical documents which aren’t Woo products. These documents would be priced at one of three price points (in a Woo Product sense).

    The customer’s path will be to land on a non-Woo page specific to a particular history document. I want the customer to press an add to cart button which would put one of the three generic products set up in Woo into the cart. BUT I’d like the Woo cart to contain a reference from the page where it was pressed which would contain details about that non-Woo document.

    If you have any links that would help me experiment that would be much appreciated?

    Thanks

    David

    (@topsquirrel)

    Same problem

    …appears to be caused by a change to navigation in header.php The new code uses this instead:-

    `<?php get_template_part( ‘template-parts/header/site’, ‘navigation’ ); ?>

    • This reply was modified 4 years, 5 months ago by David.
    Thread Starter David

    (@topsquirrel)

    Thanks for your thoughts Fernando.

    Yes, I used cart2cart to migrate the data from Joomla 1.5 to WordPress 5.0 which appears to have worked well otherwise.

    As my workaround is a plugin it was easy to deactivate and then test with a category created manually. The home page shop display is using this shortcode [product_categories number=”0″ parent=”0″ hide_empty=”0″ columns=”3″]. As hide_empty is false, I was expecting to see the new category but it didn’t display the category until I added a product to it.

    I will leave the plugin activated now as that provides a solution and the site goes live tomorrow! ??

    Many thanks again for your help!

    p.s. If anyone seeing this post wants to try the plugin, you need to change Woocommerce Product Display settings in the Customizer to have:-
    Shop Page Display = Products
    Category Display = Products

    Thread Starter David

    (@topsquirrel)

    Hi Fernando,

    Thanks for coming back again.

    One of the two sub-categories that was displaying (out of 13) had products assigned, the other had products assigned to its sub-categories. It is a puzzler what causes the problem; I wondered about database collation as the data has originally come from Joomla 1.5 in a roundabout route.

    Thank you for your help. I was completely stuck! I have now created a workaround which displays all subcategories (and the header category image). I have done this through a Plugin – see below.

    <?php
    /**
     * Plugin Name: Squirrelhouse - handle WooCommerce (sub)categories in archive pages
     * Description: Display products and categories / subcategories as two separate lists in product archive pages
     * Version: 1.0
     * Author: Squirrelhouse
     * Author URI: https://media.squirrelhouse.biz
     */
     
    /**
     * Display all sub categories based on 3 column display
     * Based on https://code.tutsplus.com/tutorials/display-woocommerce-categories-subcategories-and-products-in-separate-lists--cms-25479
     */
    function squirrel_product_subcategories( $args = array() ) {
        $parentid = get_queried_object_id();
        
        $counter = 1; //counter tracks the number of the post we're on 
             
        $args = array(
            'parent' => $parentid
        );
     
        $terms = get_terms( 'product_cat', $args );
     
        if ( $terms ) {
             
            echo '<hr><h2 class="squirrel-cat-section">Sub-Categories</h1>';
            echo '<ul class="products columns-3">';
         
                foreach ( $terms as $term ) {
                    
                    // add last or first classes          
                    ?>
                    <?php if ($counter % 3 == 0) { echo '<li class="product-category product squirrel-cat last">';} 
                      elseif ($counter % 3 == 1) { echo '<li class="product-category product squirrel-cat first">';} 
                      else                       { echo '<li class="product-category product squirrel-cat">';} 
                      ?> 
                    <?php
                             
                    // echo '<li class="product-category product squirrel-cat ">';                 
                         
                        echo '<a href="' .  esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '" squirrel-cat-a>';
                        
                        woocommerce_subcategory_thumbnail( $term );
                        
                        echo '<h2 class="woocommerce-loop-category__title squirrel-cat-h2">';
                        echo $term->name;
                        echo '</h2>';
                        echo '</a>';
                                                                         
                echo '</li>';
                
                $counter++; // This increases the value of $counter by 1 for every loop iteration 
                                                                         
            }
         
            echo '</ul>';
            echo '<hr><h2 class="squirrel-cat-section">Products</h1>';
    
     
        }
    }
    
    add_action( 'woocommerce_before_shop_loop', 'squirrel_product_subcategories', 50 );
    
    /**
     * Display category image on category archive
     * Based on https://stackoverflow.com/questions/12717112/how-to-display-woocommerce-category-image
     */
    function woocommerce_category_image() {
        if ( is_product_category() ){
    	    global $wp_query;
    	    $cat = $wp_query->get_queried_object();
    	    $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
    	    $image = wp_get_attachment_url( $thumbnail_id );
    	    if ( $image ) {
    		    echo '<img src="' . $image . '" alt="' . $cat->name . '" />';
    		}
    	}
    }
    
    add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );
    
    ?>
    Thread Starter David

    (@topsquirrel)

    p.s. I’ve now decided to overwrite the archive page handling

    Thread Starter David

    (@topsquirrel)

    Thanks for your help Fernando, much appreciated.

    I had already tried deactivating the plugins which didn’t work with Poseidon theme.

    On your advice, I tried installing Storefront and deactivating the plugins again – unfortunately that still didn’t work either.

    I’ve also tried uploading a larger category image to one of the categories that isn’t displaying but this didn’t fix it.

    Do you know where the loop is to retrieve subcategories? I’m thinking I could try debugging there perhaps but it looks quite complex.

    Thread Starter David

    (@topsquirrel)

    Just to add…

    The shop display is based on the display categories shortcode:-
    [product_categories number="0" parent="0" hide_empty="0"]

    David

    (@topsquirrel)

    Glad you found a solution ??

    David

    (@topsquirrel)

    Not sure if this helps Christopher, is it the date_format parameter you need?

    I’ve been frustrated for an hour or so using the format parameter which didn’t work for me. A couple of extra date examples in the documentation would be great wouldn’t it.

    I have a custom field populated with JQuery date picker. In the database, I’m seeing wp_postmeta.meta_value having 20180806 stored as longtext for today’s date. My custom field is called dat and I’ve used [field dat date_format=’D j M Y’] on the page which is displaying Mon 6 Aug 2018.

    Hope that helps,

    David

    Thread Starter David

    (@topsquirrel)

    Hi,
    Sorry, I can’t see any option settings – where should I look?

    Thread Starter David

    (@topsquirrel)

    btw WooCommerce Improved External Products doesn’t work for me

Viewing 15 replies - 1 through 15 (of 23 total)