• Resolved pkollias

    (@pkollias)


    Hello there. Thank you for this beautiful plugin. I’m having an issue when trying to add extra field (e.g. phone). While i manage to add it via the woo_stock_alert_fileds_array filter, and pass it through the woocommerce_product_stock_alert_form_additional_fields filter, the form value is always undefined. I think it’s beacause something is wrong with the jQuery selector in the frontend.js file, line 104 $(this).parent().find('.'+woo_stock_alert_script_data.additional_fields[i]).val();

    woo_stock_alert_script_data.additional_fields[i] is correctly named after the css class I use, but it cannot be found..

    Can you help please? Thank you in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter pkollias

    (@pkollias)

    A solution could be to replace the selector with $('.'+woo_stock_alert_script_data.additional_fields[i]).val();

    or something similar? Could you please fix it in the next version? Thank you.

    Plugin Support mouindi

    (@mouindi)

    @pkollias, sorry to hear that you have faced this issue.

    Our developer will look into this. Kindly provide them some time.

    Thread Starter pkollias

    (@pkollias)

    @mouindi , thank you. For everyone that might want to add extra field (e.g. phone), I provide the code (put in functions.php):

    function add_alert_phone_field( $array ) {

    $array[‘stock_alert_phone’] = array(
    ‘type’ => ‘text’,
    ‘class’ => ‘stock_alert_phone’,
    ‘placeholder’ => __(‘Enter your mobile phone number’, ‘woocommerce-product-stock-alert’)
    );

    return $array;

    }
    add_filter(‘woo_stock_alert_fileds_array’, ‘add_alert_phone_field’);

    function push_additional_fields( $text ) {
    return [‘stock_alert_phone’];
    }


    add_filter(‘woocommerce_product_stock_alert_form_additional_fields’, ‘push_additional_fields’);

    function woocommerce_email_footer_phone_field(){
    $stock_alert_phone = ”;
    if ( ! empty($_POST[‘stock_alert_phone’])){
    $stock_alert_phone = $_POST[‘stock_alert_phone’]; ?>

    <?php
    }
    add_action( ‘woocommerce_email_footer’, ‘woocommerce_email_footer_phone_field’ );

    • This reply was modified 1 year ago by pkollias.
    Plugin Support mouindi

    (@mouindi)

    @pkollias, I would request you to commit your code in our GitHub (https://github.com/multivendorx/woocommerce-product-stock-alert), that will be easier for the team to check the code and merge this into the plugin.

    Thread Starter pkollias

    (@pkollias)

    Thank you, i did!

    Plugin Support mouindi

    (@mouindi)

    Hi @pkollias, we have modified the code and here is the updated plugin file https://www.transfernow.net/dl/20231221DitX6b8e

    Install this file and run the above code, the addional field will be displayed.

    If you need any further help, please do let us know.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Additional fields’ is closed to new replies.