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'; ?>