Jump to content

Help with (probably) a simple problem


mnybud
Go to solution Solved by mnybud,

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.