combine woocredits into WCfM

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Tagged: 

Viewing 19 reply threads
  • Author
    Posts
    • #53890
      uwe
      Participant

      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
      Screenrecording

      We 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

    • #54053
      WCFM Forum
      Keymaster

      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

    • #54068
      uwe
      Participant

      โ€“ So, what you want? If vendor set regular price it should be automatically update โ€œ_credits_amountโ€?

      yes that is exactly what i need ๐Ÿ™‚

    • #54168
      WCFM Forum
      Keymaster

      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

    • #54261
      uwe
      Participant

      I have added that code snippet to my functions.php file, but it didn’t work

    • #54555
      WCFM Forum
      Keymaster

      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

    • #54651
      uwe
      Participant

      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 you

      Attachments:
      You must be logged in to view attached files.
    • #54655
      uwe
      Participant

      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

    • #54928
      WCFM Forum
      Keymaster

      Yeah sure, add to your child theme’s functions.php

      Thank you

    • #55280
      uwe
      Participant

      OK i did that and verified the meta key, but your code did not work

    • #55525
      WCFM Forum
      Keymaster

      HI,

      Can you please show me this code screenshot from your functions.php

      Thank You

    • #55865
      uwe
      Participant

      Of course

      see attached

      Attachments:
      You must be logged in to view attached files.
    • #55981
      WCFM Forum
      Keymaster

      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

    • #56034
      uwe
      Participant

      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

    • #56051
      Uwe Kreuzahler
      Guest

      here a screen recording of the steps i do and the functions.php
      recording

    • #56184
      WCFM Forum
      Keymaster

      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

    • #56212
      Uwe
      Guest

      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 ๐Ÿ™‚

    • #56242
      WCFM Forum
      Keymaster

      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

    • #56249
      uwe
      Guest

      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

    • #56448
      WCFM Forum
      Keymaster

      You are welcome ๐Ÿ™‚

Viewing 19 reply threads
  • The topic ‘combine woocredits into WCfM’ is closed to new replies.