Home Forums WC Vendors Pro Support frontend mycred product reward points

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #37353
    pablogala
    Participant

    Hi, I am integrating WC-Vendors-pro with mycred, and need to save the reward points of a product.

    Currently mycred has a widget on backend product page, to set reward points, so when customer buys a product he/she gets rewarded with mycred points.

    I need to move this functionality to the frontend. I managed to create a custom field, and make that field requiered and recovered data. But dowt known where or how can associate the custom field value to the mycred real value.

    (Another secondary but important issue is I can enter a negative number in stock quantity, and in my custom field and hope if there is any data-rules I can use to allow only positive numbers >0 for example.

    Thank you very much for your support,
    regards
    Sebastian

    #37378
    Jamie
    Keymaster

    Hello

    Instead of making it a custom field, make it the same meta key as what mycred uses on the backend. You will then need to hook into the product save action to save that meta key instead of using our custom key that does this automatically.

    If you ensure that all your keys line up with what mycred uses all other functionality of mycred should kick in. You can download our ‘simple auctions’ integration plugin from our site. This is a great example of how to implement a third party plugin into our front end including their meta keys.

    cheers,

    Jamie.

    #37417
    pablogala
    Participant

    Hi thanks for yout quick reply, off course i am lost… I have created the following field in product-edit.php

    The meta for my cred is mycred_reward

    <?php
    WCVendors_Pro_Form_Helper::input( array(
    ‘type’ => ‘number’,
    ‘post_id’ => $object_id,
    ‘id’ => ‘mycred_reward’,
    ‘label’ => __( ‘Puntos mycred’, ‘wcvendors-pro’ ),
    ‘placeholder’ => __( ‘Cantidad de puntos a otorgar’, ‘wcvendors-pro’ ),
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘PuntosPTP a otorgar con la venta de este producto (obligatorio).’, ‘wcvendors-pro’ ),
    ‘custom_attributes’ => array(
    ‘data-rules’ => ‘required’,
    ‘data-error’ => __( ‘Debes ingresar la cantidad de PuntosPTP que otorgas con la venta de este producto.’, ‘wcvendors-pro’ ),
    ‘data-label’ => __( ‘mycred_reward’, ‘wcvendors-pro’ ),

    )
    ) );
    ?>

    still need to have in data-rules a number greater than zero, it is possible?
    thanks very much

    #37470
    WC Vendors Support
    Participant

    You can change it from required to decimal and that would do number validation.

    #37570
    pablogala
    Participant

    Hi ben, I need numbers >0, not only numbers.

    #37605
    WC Vendors Support
    Participant

    That will be an issue then. The only data validation rules that exist are required, or decimal numbers. You would have to code in your own validation code for this one…..

    #37712
    pablogala
    Participant

    I figured it out, mycred uses an array for value in metakey mycred_reward,
    I hooked the save_post action, but still don’t known how to get the value for the custom field I have created in the WC frontend form.

    Here is my snippet code for the action, I put ?? where need any clue to get the value entered in form.

    add_action(‘save_post’, ‘guarda_post’);
    function guarda_post($post_id)
    {
    if(get_post_type($post_id) != “product”) return;

    $meta_value = get_post_meta($post_id, ‘wcv_custom_product_mycred_reward’, true);
    echo ‘That is the old value:’ . $meta_value;

    $meta_value = ??
    echo ‘Thit is the new value entered in WC Vendors Frontend form:’ . $meta_value;
    }

    #37810
    WC Vendors Support
    Participant

    Using get_post_meta would be the correct way to get a post (products) custom meta key value. If your meta key is wcv_custom_product_mycred_reward then:

    $meta_value = get_post_meta( $post_id, 'wcv_custom_product_mycred_reward', true); //true if not array, false if array

    Since your meta key starts with wcv_custom you dont have to save it on the add/edit product form, Pro automatically detects it as a field and will save it.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.