admin管理员组文章数量:1312853
Could someone kindly assist me with how to auto populate a value of Regular Price Field in Simple Product with a value that I calculate using ACF.
Here is a scenario.
- All Products in our store are Simple Products.
- We use ACF to calculate rates for the product using simple formulas and configuring different parameters.
Now, we wish to auto populate the regular Price with the Value that is generated from the Target Net Retail Price Field of the calculated Fields, if the checkbox is Yes. Else, Leave the Regular Price Blank and Let the user manually Fill it.
We will be using a Bulk Editor to input all the mandatory fields and wish to see the regular price get populated and not worry about messing up with our business numbers.
I sense the necessity to use Jquery. Could someone share an idea on how to achieve this task.
Thank you and much appreciate your time and efforts.
Could someone kindly assist me with how to auto populate a value of Regular Price Field in Simple Product with a value that I calculate using ACF.
Here is a scenario.
- All Products in our store are Simple Products.
- We use ACF to calculate rates for the product using simple formulas and configuring different parameters.
Now, we wish to auto populate the regular Price with the Value that is generated from the Target Net Retail Price Field of the calculated Fields, if the checkbox is Yes. Else, Leave the Regular Price Blank and Let the user manually Fill it.
We will be using a Bulk Editor to input all the mandatory fields and wish to see the regular price get populated and not worry about messing up with our business numbers.
I sense the necessity to use Jquery. Could someone share an idea on how to achieve this task.
Thank you and much appreciate your time and efforts.
Share Improve this question edited Dec 30, 2020 at 19:45 Koushik V asked Dec 30, 2020 at 19:27 Koushik VKoushik V 11 bronze badge1 Answer
Reset to default 0Based on a reference, I was able to populate the field of the regular price based on ACF field alue using the following Code :
add_action( 'woocommerce_process_product_meta',update_product_price_from_acf', 100, 1 );
function update_product_price_from_acf( $product_id ) {
if( $price_acf = get_field( 'netsalesprice', $product_id ) )
update_post_meta( $product_id, '_regular_price', $price_acf );
}
This, however, needs me to go into each product and click update for it to load into the regular price field and is not an automatic fix. How to make this auto populate without having to click Update on Each Product?
本文标签: functionsPopulate Product Regular Price with a calculated ACF Field Value
版权声明:本文标题:functions - Populate Product Regular Price with a calculated ACF Field Value 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741879002a2402635.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论