Mike M. a11n
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Use YARPP for Related ProductsRight now the code is setup to show either tags or categories. If no related tag products are found it tries categories and shows them. I’ll work on something can show both at the same time if there aren’t enough matching tags.
Forum: Plugins
In reply to: [WooCommerce] Free and paid shipping optionsYou can enable flat rate shipping for 1-day delivery and free shipping for 3-5 day standard delivery. Customers can choose at checkout and their totals will update accordingly. Is this what you’re doing now?
Forum: Plugins
In reply to: [WooCommerce] My Descriptions just disappeared on my website?That could certainly do it. You have a conflict somewhere or possibly outdated WooCommerce templates. In the admin section go to WooCommerce->System Status and scroll to the bottom. Does it show any outdated templates? If not, you may want to deactivate plugins one by one, checking the description each time.
Forum: Plugins
In reply to: [WooCommerce] My Descriptions just disappeared on my website?Hi Christian. Have you made any recent changes. I see the description in the page source but its set to display: none. Any recent updates?
Forum: Plugins
In reply to: [WooCommerce] Use YARPP for Related ProductsI work on this a little longer. I think this will work a little better for what you’re trying to do. This will check for related tags and show them if found. If no matching tags, it will check for categories. Otherwise, it will default to to the stand related.php code.
<?php /** * Related Products * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } global $product, $woocommerce_loop; if ( empty( $product ) || ! $product->exists() ) { return; } //If product tag, get the terms if ($product_tags = get_the_terms($product->id, 'product_tag')) { //Product Tags IDs array $product_tag_ids = array(); foreach($product_tags as $product_tag) { $product_tag_ids[] = $product_tag->term_id; } //Create the args $count_args = array( 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'no_found_rows' => 1, 'orderby' => $orderby, 'post__not_in' => array($product->id), 'tax_query' => array(array( 'taxonomy' => 'product_tag', 'field' => 'id', 'terms' => $product_tag_ids, )), ); $query = new WP_Query( $count_args ); //count products with tags $count = (int)$query->post_count; if ( $count == 0 ){ //if no related tags, try categories if ( $product_cats = get_the_terms( $product->id, 'product_cat' ) ) { //Product Tags IDs array $product_cat_ids = array(); foreach( $product_cats as $product_cat ) { $product_cat_ids[] = $product_cat->term_id; } //Create the args $count_args = array( 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'posts_per_page' => $posts_per_page, 'no_found_rows' => 1, 'orderby' => $orderby, 'post__not_in' => array($product->id), 'tax_query' => array(array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $product_cat_ids, )), ); $query = new WP_Query( $count_args ); $count = (int)$query->post_count; //if no related categories, do nothing. if ( $count == 0 ){ return; } else { //if related categories, show them $args = $count_args; } } else { //if product has tags but no related, and no categories, run default related query $related = $product->get_related( $posts_per_page ); if ( sizeof( $related ) == 0 ) return; $args = apply_filters( 'woocommerce_related_products_args', array( 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'post__in' => $related, 'post__not_in' => array( $product->id ) ) ); } } else { //if related tags found, show them $args = $count_args; } } else { //product has no tags, run default query $related = $product->get_related( $posts_per_page ); if ( sizeof( $related ) == 0 ) return; $args = apply_filters( 'woocommerce_related_products_args', array( 'post_type' => 'product', 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => $posts_per_page, 'orderby' => $orderby, 'post__in' => $related, 'post__not_in' => array( $product->id ) ) ); } $products = new WP_Query( $args ); $woocommerce_loop['columns'] = $columns; if ( $products->have_posts() ) : ?> <div class="related products"> <h2><?php _e( 'Related Products', 'woocommerce' ); ?></h2> <?php woocommerce_product_loop_start(); ?> <?php while ( $products->have_posts() ) : $products->the_post(); ?> <?php wc_get_template_part( 'content', 'product' ); ?> <?php endwhile; // end of the loop. ?> <?php woocommerce_product_loop_end(); ?> </div> <?php endif; wp_reset_postdata();
Btw, cool site and domain!
Forum: Plugins
In reply to: [WooCommerce] Use YARPP for Related ProductsOk. So by default, without any filtering or YARPP, related posts will show products with the same categories or tags. So it seems that this should be working for you out of the box. I’d remove these filters and functions, then clear transients in WooCommerce->System Status->Tools(just in case.)
Forum: Plugins
In reply to: [WooCommerce] Removing action thankyou pageI think you’ll just need to do a template override on thankyou.php.
https://docs.woothemes.com/document/template-structure/
<?php /** * Thankyou page * * @author WooThemes * @package WooCommerce/Templates * @version 2.2.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } if ( $order ) : ?> <?php if ( $order->has_status( 'failed' ) ) : ?> <p><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction.', 'woocommerce' ); ?></p> <p><?php if ( is_user_logged_in() ) _e( 'Please attempt your purchase again or go to your account page.', 'woocommerce' ); else _e( 'Please attempt your purchase again.', 'woocommerce' ); ?></p> <p> <a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e( 'Pay', 'woocommerce' ) ?></a> <?php if ( is_user_logged_in() ) : ?> <a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php _e( 'My Account', 'woocommerce' ); ?></a> <?php endif; ?> </p> <?php else : ?> <p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p> <?php endif; ?> <?php //do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?> <?php //do_action( 'woocommerce_thankyou', $order->id ); ?> <?php else : ?> <p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p> <?php endif; ?>
Forum: Plugins
In reply to: [WooCommerce] Undefined index: list_class at mini-cart.php – line 20It looks like the mini-cart.php template is explicitly echoing
$args['list_class']
. When you usewc_get_template( 'cart/mini-cart.php');
, the template can’t find the argument because it doesn’t exist.But, when you call the function
woocommerce_mini_cart()
, you shouldn’t need to pass any arguments if you don’t want to, as it setslist_class
to an empty string as a default. I think I tried this and still received an error though.Either way, you could just use an empty sting if you don’t want to add a class.
<?php wc_get_template( 'cart/mini-cart.php', array('list_class' => '')); ?>
Forum: Plugins
In reply to: [WooCommerce] In Which Template Is The Variation Description CodeIt doesn’t look like there is a good way to do this currently. In woocommerce/single-product/add-to-cart/variable.php there is a hook
woocommerce_single_variation
where the variable description is being added. It seems like that hook isn’t doing anything at all. The variation description is being added after the fact with jQuery.If you’re good with jQuery you might be able to move it around.
Forum: Plugins
In reply to: [WooCommerce] Undefined index: list_class at mini-cart.php – line 20You need an array containing
list_class
as a second argument. The class you specify will be added to the first<ul>
in the widget.This should work:
<?php wc_get_template( 'cart/mini-cart.php', array('list_class' => 'example-class')); ?>
You could also use:
<?php woocommerce_mini_cart(array('list_class' => 'example-class')); ?>
Forum: Plugins
In reply to: [WooCommerce] Use YARPP for Related ProductsYes I would remove that code. So you’re hoping to show related products with the same tag and same category?
Forum: Plugins
In reply to: [WooCommerce] adding products on the checkout pageNo problem. You should test, adding multiple products, to make sure this is working on your server. You may need to increase the delay time or may be able to lower/remove it altogether.
Forum: Plugins
In reply to: [WooCommerce] adding products on the checkout pageWithout seeing your JS file, I can’t say exactly where to put it. It should be inside of a wrapper like:
(function ($) { //add the function here }(jQuery));
or you could replace the $ with the word jQuery in both spots in the code I posted earlier. If you can’t work it out, post your JS file and I’ll let you know.
Forum: Plugins
In reply to: [WooCommerce] adding products on the checkout pageYeah. Any JS file that will be called on that page. Typically your theme will have a scripts.js, or custom.js you can use. Some themes have a panel in the theme options section for custom JS.
I tried a lot of different combinations with hooks to no avail. I have a feeling there is a better solution using hooks. I’d be curious to see it.
Forum: Plugins
In reply to: [WooCommerce] adding products on the checkout pageHi. I’ve managed to get this working via jQuery.
$('.woocommerce-checkout .add_to_cart_button').click(function(){ setTimeout(function(){ $( 'body' ).trigger( 'update_checkout' ); }, 1000); });
This will run the
update_checkout
function 1 second after the add to cart button has been clicked on the checkout page. I added the timeout because I found that sometimes the cart would refresh before the product was added.