Home Forums LoveStory Memberships

Memberships

  • net2ride

    How / Where do I add a cost per membership level and credit card processing?

    ihor Staff

    Please sign in or register to view replies from the support staff.

    prometeosp

    Dear ihor,

    On my website, there is an online shop where you can buy not memberships, but bundles like ten messages, ten gifts, and so on.

    My problem is, how can I link my woocommerce product with the user profile? I mean, if the user buys this product, I should update their profile to add this number of messages, or gifts, or whatever.

    I don’t want to add as a membership because it will be a very long list, and the people do not know what to buy.

    Kind regards,

    Frank

    ihor Staff

    Please sign in or register to view replies from the support staff.

    prometeosp

    Dear ihor,

    I changed the completeOrder function in this way:

    /**
    * Completes order
    *
    * @access public
    * @param int $ID
    * @return void
    */
    public static function completeOrder($ID) {

    global $product;

    $post=self::getRelatedPost($ID, ‘membership’);
    if(!empty($post)) {
    ThemexUser::addMembership($post->post_author, $post->ID, false);
    } else {
    $order = wc_get_order( $ID );
    $items = $order->get_items();
    $user_id = $order->get_user_id();
    $membership=ThemexCore::getUserMeta($user_id, ‘membership’);
    foreach ( $items as $item ) {
    $product_id = $item->get_product_id();
    $product = wc_get_product($product_id);
    if ( has_term( ‘mensajes’, ‘product_cat’, $product_id ) ) {
    $quantity = intval($product->get_attribute( ‘messages’ ));
    ThemexUser::updateMembership($user_id, ‘messages’, $quantity);
    } elseif ( has_term( ‘regalos’, ‘product_cat’, $product_id ) ) {
    $quantity = intval($product->get_attribute( ‘gifts’ ));
    ThemexUser::updateMembership($user_id, ‘gifts’, $quantity);
    } elseif ( has_term( ‘fotos’, ‘product_cat’, $product_id ) ) {
    $quantity = intval($product->get_attribute( ‘photos’ ));
    ThemexUser::updateMembership($user_id, ‘photos’, $quantity);
    }
    }
    }
    }

    But when I call the updateMembeship it erases the membership, and there is only one array member with messages, gifts, or photos.

    How can I update the membership without losing the previous content? Should I make another updateMembership function?

    Kind regards,

    Frank

    ihor Staff

    Please sign in or register to view replies from the support staff.

    prometeosp

    Dear ihor,

    Did you review the code that I just sent you?

    I don’t mind to be rude, but your answer is a littble bit disappointing. Could you develope the answer a little bit, please?

    Kind regards,

    Frank

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.