Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › combine woocredits into WCfM
Tagged: woocredit
- This topic has 19 replies, 3 voices, and was last updated 5 years, 1 month ago by WCFM Forum.
- AuthorPosts
- March 21, 2019 at 9:41 pm #53890uweParticipant
Hello
i’m using woocredits as 2nd payment option and i need to find a way to put the regular price (during product setup) into the Credit field (custom field who has been assigned to the meta data “_credits_amount” (i did verify that the field actually pulls the correct data from woocredit, if i add it to the product using WP-Admin
The reason for that is that i want my Vendors not getting confused with the regular price and credit price (they have to be in sync)
Hera a link to a screenrecording, which will explain the situation better
ScreenrecordingWe did try to modify wcfm-controller-products-manage.php but only could get it to work in reverse order, meaning the credits actually did overwrite the regular price
I hope that i have been clear with the explanation of the issue we are trying to solve, please let me know if you need any additional information
thanks
Uwe
- March 22, 2019 at 4:52 pm #54053WCFM ForumKeymaster
HI,
The reason for that is that i want my Vendors not getting confused with the regular price and credit price (they have to be in sync)
– So, what you want? If vendor set regular price it should be automatically update “_credits_amount”?
Thank You
- March 22, 2019 at 5:29 pm #54068uweParticipant
โ So, what you want? If vendor set regular price it should be automatically update โ_credits_amountโ?
yes that is exactly what i need ๐
- March 23, 2019 at 11:49 am #54168WCFM ForumKeymaster
Hi,
Please use this code snippet –
add_action( 'after_wcfm_products_manage_meta_save', function( $new_product_id, $wcfm_products_manage_form_data ) { if( isset( $wcfm_products_manage_form_data['regular_price'] ) ) { update_post_meta( $new_product_id, '_credits_amount', wc_clean( $wcfm_products_manage_form_data['regular_price'] ) ); } }, 50, 2 );
Thank You
- March 23, 2019 at 6:48 pm #54261uweParticipant
I have added that code snippet to my functions.php file, but it didn’t work
- March 26, 2019 at 1:39 pm #54555WCFM ForumKeymaster
Hi,
Well, then this meta key is not right “_credits_amount”
You may check from database, this code saving regular price in “_credits_amount” meta as well.
Thank You
- March 26, 2019 at 7:07 pm #54651uweParticipant
the meta key is correct, i just double checked – see screenshot
Also i’m able to add woocredits using WCfM frontend (added customfield) with the same meta key. Which actually prooves that the met key was correct, as i explained in my very first post.
So, please tell me how i can get this fixed.
Thank youAttachments:
You must be logged in to view attached files. - March 26, 2019 at 7:09 pm #54655uweParticipant
just to verify, i did try to add your code to my functions.php – Assuming that this is the correct file. Please let me know
- March 28, 2019 at 11:03 am #54928WCFM ForumKeymaster
Yeah sure, add to your child theme’s functions.php
Thank you
- March 29, 2019 at 9:12 pm #55280uweParticipant
OK i did that and verified the meta key, but your code did not work
- April 1, 2019 at 4:55 am #55525WCFM ForumKeymaster
HI,
Can you please show me this code screenshot from your functions.php
Thank You
- April 2, 2019 at 9:42 pm #55865
- April 3, 2019 at 8:32 am #55981WCFM ForumKeymaster
HI,
Code is perfect. Again checked, it’s store data perfectly in database – https://ibb.co/M8ZMryy
Between, are you creating product from backednd or using WCFM product manager?
Thank You
- April 3, 2019 at 2:32 pm #56034uweParticipant
I don’t understand why it is not working then
i use the WCFM product manager (frontend) to add a new product and it does not update
- April 3, 2019 at 3:51 pm #56051Uwe KreuzahlerGuest
here a screen recording of the steps i do and the functions.php
recording - April 4, 2019 at 3:43 pm #56184WCFM ForumKeymaster
HI,
Ahh .. you never told me, you have added that field using WCFM custom field.
Use this modified code –
add_action( 'after_wcfm_products_manage_meta_save', function( $new_product_id, $wcfm_products_manage_form_data ) { if( isset( $wcfm_products_manage_form_data['regular_price'] ) ) { update_post_meta( $new_product_id, '_credits_amount', wc_clean( $wcfm_products_manage_form_data['regular_price'] ) ); } }, 250, 2 );
Thank You
- April 4, 2019 at 4:14 pm #56212UweGuest
Hi
well, i did wrote that i tested it inside the custom field, but you are right, i should have been more clear about this
Long story short, your new code does work!!!!!!!!!
Thank you so much for your help ๐
- April 4, 2019 at 4:44 pm #56242WCFM ForumKeymaster
You are welcome ๐
Actually, this hook priority causing issues – 250
Previously I had set this 50, but WCFM custom field save work at 200, so that fields empty value was overwrite that.
Thank You
- April 4, 2019 at 4:58 pm #56249uweGuest
Yes, i did noticed that the only change needed to get it to work was the change form -50 to -250
Incredible to realize how a single digit can change the outcome ๐
Thanks again for your help
- April 6, 2019 at 8:16 am #56448WCFM ForumKeymaster
You are welcome ๐
- AuthorPosts
- The topic ‘combine woocredits into WCfM’ is closed to new replies.