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.

  1. All Products in our store are Simple Products.
  2. 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.

  1. All Products in our store are Simple Products.
  2. 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 badge
Add a comment  | 

1 Answer 1

Reset to default 0

Based 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