• Good Day

    I have a custom form with an email input field, and a submit button, along with a product name, permalink, and slug. How can I send these info to the back-in-stock-notifier plugin via php.

    I need something like

    <form method="POST" action = "the/url/here.php">
    <!-- input and buttons -->
    </form>
    

    I need to know which php file the custom form should submit to, and what parameters should be included, so that the email address and the product name/slug can be included in the same database of waitlisted emails maintained by the plugin.

    A sample php code will be awesome, Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Good Day!!

    Could you please provide us with more information about your specified custom form (whether it is from another plugin or from another source) so that we can better assist you?

    Let us know.

    Thanks.

    Thread Starter seanyscon

    (@seanyscon)

    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>&nbsp;&nbsp;&nbsp;&nbsp;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.

    Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Thanks for the information.
    ?
    We use ajax action to perform subscription in the frontend. We suggest you use this action, “cwginstock_product_subscribe.” You can find this in the file: “class-ajax.php” on our end.
    ?
    We’ve also taken note of your requested feature of binding registered email to the subscribe button directly for subscription at the click the button, and we’ll try to bring this in our upcoming versions as per the feasibility.

    Have a cheerful day!
    ?
    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to submit an email address from a custom form’ is closed to new replies.