Jump to content

mnybud

Members
  • Posts

    80
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

mnybud's Achievements

Member

Member (2/5)

0

Reputation

1

Community Answers

  1. Good advice but I am not very good at PHP (obviously) so did what I could figure out and modified it in a way that works for me. It has been this way for over a year with no problems There is not a good way to filter out products in woocommerce for my use as I am actually filtering out the $0 products and not actual out of stock items. Thanks again for the advice but for now I am just looking for a way to modify the code above.
  2. Hi. I need some help making some changes to some code. I have tried several things and still can't seem to get it right so hoping someone here can help me out. This is the original code I wrote that I am trying to change.... <?php do_action( 'woocommerce_before_shop_loop_item' ); ?> <a href="<?php the_permalink(); ?>"> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action( 'woocommerce_before_shop_loop_item_title' ); ?> <?php echo $product->is_in_stock() ? '' : '<img src="notavailable.png" class="attachment-shop_catalog wp-post-image">'; ?> <h3><?php the_title(); ?></h3></a> <?php do_action( 'woocommerce_after_shop_loop_item' ); ?> What I am trying to accomplish is to make it so my shop only shows the product if it is in stock. Currently the code above adds a notavailable.png to out of stock items but still displays them. I tried something like this but I am not able to make it work. <?php echo $product->is_in_stock() ? ' <?php do_action( 'woocommerce_before_shop_loop_item' ); ?> <a href="<?php the_permalink(); ?>"> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action( 'woocommerce_before_shop_loop_item_title' ); ?> <h3><?php the_title(); ?></h3></a>' : ''; ?> <?php do_action( 'woocommerce_after_shop_loop_item' ); ?> If anyone can help me get this right I would really appreciate it.
  3. never mind I figured it out
  4. I have limited PHP knowledge and have been fighting with something that is probably not to hard for you PHP freaks so hoping someone can provide me with a solution. Here is what I am trying to accomplish... I have this code that works. <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $product; ?> <?php echo $product->is_in_stock() ? 'in stock' : 'out of stock'; ?> What I am trying to get working is this below but so far I am having no luck figuring it out with my lack of PHP knowledge. More or less I am trying to echo my form which has some other PHP code that breaks it. Can anyone help? Thanks so much in advance! <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $product; ?> <?php echo $product->is_in_stock() ? ' <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?> <form name="order" action="<?php echo esc_url( $product_url ); ?>" method="post"> <input type="image" src="image.png" onClick="ga('send', 'event', { eventCategory: 'Button', eventAction: 'click', eventLabel: 'Button'});"/> </form> <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?> ' : 'out of stock'; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.