By referencing to the source code, this function supports an argument called value
which you can pass one of the keys inside the options
array like this:
function woo_add_spin() {
woocommerce_wp_select([
'id' => '_select_nf',
'label' => __( 'Select #spins: ', 'woocommerce' ),
'selected' => true,
'value' => '24',
'options' => [
'24' => __( '24', 'woocommerce' ),
'36' => __( '36', 'woocommerce' ),
'48' => __( '48', 'woocommerce' )
]
]);
}
By looking inside the source code, WooCommerce also tries to fetch the value of the select field using the id
field and the post meta but, you can’t take advantage of this built-in feature because you’re saving the settings inside the wp_options
table.
Related Posts:
- How to Remove Active css from woocommerce variation?
- Can’t add Select2 to select in variable product (admin)
- Woocommerce add a text field if specific option is selected
- wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?
- Create WooCommerce custom stock option that is non-purchasable
- Query multiple post type and categories
- Shipping restrictions with WooCommerce variable products
- WooCommerce – Flat rate shipping based on X quantity steps?
- Custom URL for each product variation – rewrite rules
- Where can I find a single item template
- Get Woocommerce Subscription Product
- Change “Shipping” text to “Delivery” everywhere I appears in woocommerce
- Customize WooCommerce orders displayed shipping
- WooCommerce pages accessible to logged in members only
- creating product with variations using woocommerce REST API
- Adding extra one email address who receives email as admin – woocommerce
- Woocomerce language
- How to set default values in Woocommerce checkout? [closed]
- paypal not showing on woocommerce payments
- Payment methods are not displaying in Woocommerce
- How to update the WooCommerce cart Icon to show new products added with JavaScript
- how i can add more required * fields in checkout page?
- Disable Local Attributes woo commerce
- What will make Woocommerce REST API to issue 401 [closed]
- Woocommerce set cookie after a sale [closed]
- How to upload images from wordpress front-end (the first image must be thumbnail and the rest without first must be in gallery woocommerce product)
- Problems with varibel price [closed]
- Custom Admin Email Subject for Woocommerce (3.8.0) Orders
- the_widget() – filter only one instance
- WooCommerce – Exclude category from snippet
- Replacing products on Woocommerce Product Category with Search Results from SearchWP [closed]
- Creating custom permalink tags for WooCommerce
- Add Custom Slug Tags Per Page
- How to override Woocommerce functionality in Reports section?
- how can use woocommerce add to cart popup?
- wc_get_products() not return the images details
- Adding Product Name on Admin Panel Order list and User’s My-Account Order List
- How to put Stripe first, PayPal second on the checkout page?
- How to change product thumbnail size in storefront theme
- woocommerce – how to get product link by id
- woocommerce_register_post action not firing [closed]
- Search in 1) Post, 2) Products (woocommerce) and 3) Custom post type or Taxonomy type on a single page
- Woocommerce REST API – add filter to set maximum query per page for product brands [closed]
- display product’s category static slider name and image in loop wordpress
- Whitespace between product image and gallery on initial load of lightbox product page
- Why is my WordPress login credentials missing, but work with WooCommerce?
- Update Customer JWT Woocommerce
- Send admin new order email to logged in user as well
- How to reverse/swap the order of “Sales price” and “Regular prcie” in woocommerce?
- Woocommerce Canceled Order Notification email to admin
- Woocommerce before and after shop loop not works
- WooCommerce Admin order – Only run action if user is loaded
- Creating child theme out of Coeur
- Hide sidebar and change layout Blog Page using is_page() function
- Change Out of Stock Error Message in WooCommerce Cart
- I want a simple dropdown for locations in woocommerce
- Getting hundreds of spam orders in WooCommerce with failed stripe payment [closed]
- How to fetch woocommerce highest price and lowest price in custom template page?
- Please help me get rid of conflict with the JavaScript – I’m using WooCommerce with product blocks (Gutenb)
- Order Status without Email check. Only with Order-Number
- WooCommerce pagination: remove ‘page’ from url
- Coupon for product / woocommerce
- How can I show “sold out” instead of “out of stock” for some products with particular tags and categories [closed]
- wc_get_product_id_by_sku() returns 0 for products added programatically via update_post_meta
- Display “Add to basket” and “Read more” buttons in the products shop page with woocommerce
- How Can I fix Woocommerce Billing Address Field? [closed]
- Assign user role by text field in WordPress (Woocommerce) [closed]
- How to display woocommerce product details on wp page
- How to set up dynamic purchase pixel in Woocommerce?
- MySQL error or data corruption after database migration
- My products are showing “not in stock” and I don’t know why
- Woocommerce change the price of products in the database
- Select all products that have a custom field ‘is_new’ set to ‘Yes’
- Woocommerce – Shop can’t find products after domain name change
- “error_message”: “Sorry, you cannot list resources.” using WooCommerce API
- Removing Product from Woocommerce checkout page using Ajax
- add_post_meta on subcription renewal
- login or register then access woocommerce website
- Move woocommerce shop page image to left
- WooCommerce Tax Filter Not Working
- WooCommerce does not translate every string
- Replace product link with just product name on WooCommerce downloads page
- Woocommerce Product category base same as product base causes 404
- Categories and products in cart Woocommerce
- SyntaxError: unterminated string literal – if WordPress Debug in wp-config is set to true
- Update Custom Post Meta Even if Draft
- Clone and modify Woocommerce Products catalog
- Custom CSS Not working on Product page
- How to add ajax loading icon after click add to cart button on woocommerce
- Can’t display product categories on woocommerce getting Invalid taxonomy?
- Send form data to functions.php
- Override woocommerce template from parent theme
- Create custom add to cart in WordPress
- WooCommerce – How to add a custom field to only a specific email template [closed]
- registration_errors not working
- How do I remove the recurring total from thank you for your order email?
- I want to Display custom woocomerce meta box in orders list
- Detect Product Type with code
- Verify if woocommerce supports this design [closed]
- Hook for Woocommerce checkout fields