I am creating woocommerce plugin and I have a custom order status “wc-shipped”. I want to execute some plugin options for this custom order status only. Here is my code
add_action('text_sms_form_fields', 'sms_woocommerce_fields', 10, 1); function sms_woocommerce_fields($textme_option, $wc_statuses_arr) { ?> if( isset( $wc_statuses_arr['wc-shipped'] ) ) { ?> <hr> <fieldset> <label for="textme_order_shipped"> <input name="textme_order_shipped" type="checkbox" id="textme_order_shipped" <?php if ($textme_option['textme_order_shipped'] == "1") { echo 'checked'; } ?> value="1"/> <span><?php esc_html_e('Send SMS when order status is shipped ', 'send_sms'); ?></span> </label> </fieldset> <div class="textme_order_shipped_content <?php if ($textme_option['textme_order_shipped'] != '1') { echo 'hidden'; } ?>"> <table> <tr> <td></td> <td><textarea id="textme_order_shipped_sms_customer" name="textme_order_shipped_sms_customer" cols="80" rows="3" class="all-options"><?php if ($textme_option['textme_order_shipped_sms_customer']) { echo $textme_option['textme_order_shipped_sms_customer']; } ?></textarea> </td> </tr> </table> </div> <?php } ?>
I want if “wc-shipped” status exist then show these plugin options but I am getting below error.
How to fix this ?
Advertisement
Answer
Your hooked function has 2 variables (arguments), so you need to declare those 2 variables replacing the first line of your code:
add_action( 'text_sms_form_fields', 'sms_woocommerce_fields', 10, 1 );
simply by:
add_action( 'text_sms_form_fields', 'sms_woocommerce_fields', 10, 2 );
This should solve this problem. See WordPress add_action()
…