Hi
It is a custom button I added to some products, via the functions.php script. The code is:
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_custom_sale_text', 10 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_custom_sale_text', 10 );
function woocommerce_custom_sale_text()
{
global $post,$product;
if ( ! $product->is_in_stock() ) {
echo '<div ' ;
echo 'class="openPopUp wd-buy-now-btn button alt add_to_cart_button ajax_add_to_cart add_no_loop" ';
echo 'style="background-color:rgba(255,255,255,0.75);color:rgb(255,153,0); position: absolute;top: 10%; left: 50%;transform: translate(-50%, -90%);-ms-transform: translate(-50%, -90%);';
echo 'border: 4px solid;border-color:rgb(255,153,0);border-radius:10px;">';
echo '<i class="fa fa-bell" aria-hidden="true"></i> Verfügbarkeitsalarm</div>';
echo '<div id="popup" class="popup" style="display:none;position:absolute;top:50%;left:50%;';//transform:translate(-50%, -05%);';
echo 'z-index:10000;background-color:#FDFDFD;width:1000px;padding:20px;border: 4px solid;border-color:rgb(255,153,0);border-radius:5px;" onclick="event.preventDefault();event.stopPropagation();">' ;
echo '<p onclick="event.preventDefault();event.stopPropagation();">M?chten Sie benachrichtigt werden, wenn dieses Produkt wieder auf Lager ist?</p>'; // Text
$params = apply_filters( 'woocommerce_bis_front_end_params', array(
'version' => WC_BIS()->get_plugin_version(),
'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
'registration_form_nonce' => wp_create_nonce( 'wc-bis-registration-form' )
) );
echo '<input type="hidden" class="cwg-security" name="cwg-security" value="' . /*wp_create_nonce('codewoogeek-product_id-' . $product)*/ '5e167eac74' . '"/>';
echo '<input type="hidden" class="cwg-productID" name="cwg-productID" value="'. $product->get_id() . '"/>';
echo '<input type="hidden" class="cwg-ajaxURL" name="cwg-ajaxURL" value="' . '/?wc-ajax=%%endpoint%%&elementor_page_id=' . $product->get_id() . '"/>';
if ( ! (is_user_logged_in()) ) echo '<input class="cwg-email" name="cwg-email" type="text" placeholder="Enter your e-mail" onclick="event.preventDefault();event.stopPropagation();">';
echo '<button class="button" type="button" onclick="submitData_frompopUP();">';
echo 'Ja </button>';
echo '</div>';
}
}
Functions.php has enqueued my own script file, script.js. My goal is to define the submitData_frompopUP(); function in the file script.js, such that when the onclick action is triggered, the content of the cwg-email item will be submitted to the plugin, along with the product id, so that once the product is back in stock, an email will be sent to this email.
Alternative : I want to bind the register email for when a product is back instock functionality to a custom button, as above.
Thank you.