Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards

zondac12

Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • in reply to: Override ‘get_item_commission’ function #142015
    zondac12
    Participant

    Hello,

    I have tried this in function.php:

    add_filter(‘vendor_commission_amount’, ‘my_function’,99,5);
    function my_function($amount, $product_id, $variation_id, $item, $order_id, $item_id) {
    foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘SMALL’) {$new_amount = 12;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘MEDIUM’) {$new_amount = 30;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘LARGE’) {$new_amount = 90;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘GIANT’) {$new_amount = 120;}
    $amount = $new_amount;
    }
    return apply_filters(‘vendor_commission_amount’, $amount, $product_id, $variation_id, $item, $order_id, $item_id);
    }

    But it doesn’t work.

    I am not sure how to override a apply_fitler.

    Best

    in reply to: Override ‘get_item_commission’ function #141967
    zondac12
    Participant

    Thank you very much. I understand, looking forward the answer.

    All the best
    Loic

    in reply to: Override ‘get_item_commission’ function #141934
    zondac12
    Participant

    Hello, sorry for the long time to answer…

    On the file “class-wcmp-calculate-commission.php” located in plugins/dc-woocommerce-multi-vendor/classes, on line 559, I inserted this code:

    foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘SMALL’) {$new_amount = 10;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘MEDIUM’) {$new_amount = 30;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘LARGE’) {$new_amount = 90;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘GIANT’) {$new_amount = 120;}
    $amount = $new_amount;
    }

    It is inserted BEFORE return apply_filters(…..) which is at line 559.

    Thank you in advance for the help.

    Kindest
    Loic

    in reply to: Override ‘get_item_commission’ function #141054
    zondac12
    Participant

    Hello,

    No, my variations are not made with Woocommerce attributes, but Custom Product Addons plugins, which is why I can’t use your commission by variation setting. Variations are only visible in the purchased product metadata.

    What I do with this code:

    foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘SMALL’) {$new_amount = 10;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘MEDIUM’) {$new_amount = 30;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘LARGE’) {$new_amount = 90;}
    $amount = $new_amount;
    }
    return apply_filters(‘vendor_commission_amount’, $amount, $product_id, $variation_id, $item, $order_id, $item_id);

    is look for the variation in the product metadata and apply the right amount for the commission.

    This code works in the core file, I really just need to know how I can safely override it in my child theme.

    Kindest
    Loic

    in reply to: Override ‘get_item_commission’ function #141030
    zondac12
    Participant

    Hello,
    I sell art prints of artists registered as vendors. Prints are available in 3 sizes (S, M and L), Framed or Unframed.

    Artists gets a commission when someone purchases one of their prints as follow (same commission if print is sold framed or unframed):
    S Unframed – Sell price 50€ – Artist gets 10€
    M Unframed – Sell price 150€ – Artist gets 30€
    L Unframed – Sell price 300€ – Artist gets 90€
    S Framed – Sell price 150€ – Artist gets 10€
    M Framed – Sell price 250€ – Artist gets 30€
    L Framed – Sell price 500€ – Artist gets 90€

    I access the ‘get_item_commission’ (located in class-wcmp-calculate-commision.php) function, in which I added:

    foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘SMALL’) {$new_amount = 10;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘MEDIUM’) {$new_amount = 30;}
    if (trim(strip_tags(wp_kses_post( $meta->display_value ))) == ‘LARGE’) {$new_amount = 90;}
    $amount = $new_amount;
    }
    return apply_filters(‘vendor_commission_amount’, $amount, $product_id, $variation_id, $item, $order_id, $item_id);

    Pricing and product variation is made with Custom Product Addons (https://acowebs.com/woo-custom-product-addons/), which is why I go through item metadata to check if size is SMALL, MEDIUM or LARGE.

    It works well, but only when written in the core file, I cannot override it…

    Best
    Loic

    in reply to: Restrict Order Status SHIPPED / COMPLETED #136669
    zondac12
    Participant

    Hello,

    OK I understand what was wrong: Order was set as Completed, but Suborder was still set at Processing. I saw that with your test purchase! Thank you.

    By the way, what is the difference between an Order and a Suborder??

    in reply to: Restrict Order Status SHIPPED / COMPLETED #136649
    zondac12
    Participant
    This reply has been marked as private.
    in reply to: Restrict Order Status SHIPPED / COMPLETED #136454
    zondac12
    Participant

    One other detail: in settings, if I check only On Hold (and not Processing or Completed), ALL orders (which are in Processing and Completed status) show in the withdrawal table…

    in reply to: Restrict Order Status SHIPPED / COMPLETED #136450
    zondac12
    Participant

    Hello, thank you for your answer.

    I was able to change back to “Shipped” status to the Woocommerce default “Completed”. But it still doesn’t work. I deactivated the Advanced Tracking plugin to be sure.

    Please find attached what I mean : last order is marked as Completed (see attached), and should appear in the vendor Withdrawal table but no (see attached). Settings attached too.

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