Home Forums WC Vendors Free Support Integrating Packages Configuration for WooCommerce

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 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #12059
    Jordan
    Participant

    Continuing the discussion here, I am trying to figure out how to give shipping fees to my vendors automatically during checkout. Basically, if you’re using USPS, FedEx, UPS, and other common shipping calculators, then you’re out of luck. For my site, being competitive is important and flat/table rate shipping fees aren’t always accurate and can lead to rates being too high, which can lead to fewer sales, or it can be too low, which means I have to pay the difference in shipping fees (which sucks!). The plugin Packages Configuration for WooCommerce will separate the shipping costs for an order based on the product’s author (vendor). It then stores these as separate shipping line items in the order like so:

    Using the Packages Configuration plugin, you can define which shipping methods are allowed per vendor. So if your store uses USPS and another uses FedEx, you can do that. It splits the order into packages based on vendor and the customer selects a suitable shipping option from the list of available options (seen below).

    One caveat to this^: you must split packages by shipping class in order to selectively allow shipping methods per vendor. I’m sure this can be modified to get around needing to use classes.

    I’m basically looking for help on how to go about doing this. When WC Vendors determines how much money to give to a vendor, I want to make it detect if the Packages Configuration plugin is active and then add the calculated shipping amount to each vendor’s dues if applicable.

    I see that the method WCV_Vendors::get_vendor_dues_from_order() (wc-vendors\classes\class-vendors.php) loops through each product in the customer’s order and figures out how much to give to the vendor by running WCV_Shipping::get_shipping_due(). I noticed there’s a filter ‘wcvendors_shipping_due’, BUT this fires for each product in the order (only products owned by a vendor) and the Packages Configuration plugin gives a grand total for the cart, NOT each individual product! So this filter can’t be used (unless you divide the total shipping cost by how many products there are, which is kind of weird).

    Long story short, if I somehow build an array with the keys being vendor IDs and the values being the amount of shipping due to them, how would I go about telling WC Vendors to give $x.xx to the store and $x.xx to a vendor?

    Any other info/notes I should be aware of?

    #12108
    WC Vendors Support
    Participant
    #12406
    Jordan
    Participant

    Any luck, Jamie? I’ll buy you a coffee!

    #12409
    WC Vendors Support
    Participant

    I’ll tag him again. 🙂 @digitalchild gets his attention, of course, use only when necessary. 🙂

    #12423
    Jamie
    Keymaster

    Hello,

    I would have to look into this further but I could probably add a few hooks for you to make this possible. I can’t look into it until I finish the shipping module unfortunately.

    cheers,

    Jamie.

    #12436
    Jordan
    Participant

    Thank you for the response Jamie. Unfortunately, this problem has become a borderline breaking issue for my site and it’s quickly reaching a point where I need to either find a solution or find a different piece of software because my vendors and supervisor are growing rather impatient. I know different sites have different needs so please do not think I am blaming WC Vendors. It’s just the situation I happen to be in at the moment. The company I’m with, PLAYlive Nation, is expanding fast with 10 stores open now and 50 more planned/signed for the coming 2 years (including 5 more by the end of this year). We have 4 vendors who are selling products and not getting paid their shipping dues and I’m the guy they’re all complaining to (it’s less fun than it sounds 😉 ).

    That being said, I am more than willing to compensate you for your time if you would be willing to put this at a high priority. How much would it take to get this bumped to the top of your to-do list?

    #13581
    Jordan
    Participant

    Well I got impatient and went ahead and made a band-aid plugin to use until the official plugin is updated. See it here: http://pastebin.com/qF94eyz3 | Download it here: https://goo.gl/Y8iNzE (or see attachment to this post).

    With that plugin active, I can run WCV_Vendors::get_vendor_dues_from_order() on an order and get this response:

    array(2) {
      [1]=>
      array(6) {
        ["vendor_id"]=>
        int(1)
        ["qty"]=>
        int(13)
        ["commission"]=>
        float(83.45)
        ["total"]=>
        float(89.4)
        ["shipping"]=>
        float(5.95)
        ["tax"]=>
        float(0)
      }
      [109673]=>
      array(6) {
        ["vendor_id"]=>
        int(109673)
        ["commission"]=>
        float(48.45)
        ["shipping"]=>
        float(6.7)
        ["tax"]=>
        float(0)
        ["qty"]=>
        int(7)
        ["total"]=>
        float(55.15)
      }
    }

    Notice the shipping field in the 2nd item in the array is populated with “float(6.7)”, meaning the vendor is getting paid their shipping dues during checkout! 🙂
    Note: shipping taxes should work too. I tested with them on then later turned them back off after seeing they were calculated correctly.

    Here’s the results from my tests:
    —————————————————
    Cart Totals
    Copied from an order. The total dues were calculated manually.
    —————————————————

    Store: $29.49
    Vendor: $38.50
    Cart Subtotal: $67.99

    Shipping #1 (Store): USPS Priority Mail®: $5.75
    Shipping #2 (Vendor): USPS Priority Mail®: $5.95

    Total Due to Store: $35.24
    Total Due to Vendor: $44.45

    Order Grand Total: $79.69

    —————————————————
    PayPal Payment
    Copied directly from PayPal’s checkout
    —————————————————
    Store: $35.24 USD
    Vendor: $44.45 USD

    Total: $79.69 USD

    So anyways, while testing in PayPal’s sandbox mode, I kept getting the error:

    Error ID: 580023. The total invoiced amount for {OMITTED} does not match the amount in the pay request

    I’m not sure if that’s because my test site is local (not accessible from PayPal’s servers) or if there’s another problem going on. I plan on testing from my live server pretty soon.

    #13584
    Jordan
    Participant

    Tested on my live site, same PayPal error.

    PayPal request log:

    [03-Nov-2015 01:07:45 UTC] PPAPIService: Request: requestEnvelope.errorLanguage=en_US&payKey={omitted}&senderOptions.requireShippingAddressSelection=1&receiverOptions(0).invoiceData.item(0).name=3-In-1+Console+Audio%2FVideo+Cables&receiverOptions(0).invoiceData.item(0).identifier=16763&receiverOptions(0).invoiceData.item(0).price=19.99&receiverOptions(0).invoiceData.item(0).itemPrice=19.99&receiverOptions(0).invoiceData.item(0).itemCount=1&receiverOptions(0).invoiceData.item(1).name=ArctiClean+30ml&receiverOptions(0).invoiceData.item(1).identifier=5737&receiverOptions(0).invoiceData.item(1).price=9.5&receiverOptions(0).invoiceData.item(1).itemPrice=9.5&receiverOptions(0).invoiceData.item(1).itemCount=1&receiverOptions(0).invoiceData.totalTax=0.00&receiverOptions(0).invoiceData.totalShipping=11.70&receiverOptions(0).receiver.email=duncan.wood-facilitator%40yahoo.com&receiverOptions(1).invoiceData.item(0).name=36pc++D6+dice+sets+%285+ct%29&receiverOptions(1).invoiceData.item(0).identifier=44223&receiverOptions(1).invoiceData.item(0).price=37.5&receiverOptions(1).invoiceData.item(0).itemPrice=37.5&receiverOptions(1).invoiceData.item(0).itemCount=1&receiverOptions(1).invoiceData.item(1).name=900+ct+Cardboard+Card+Storage&receiverOptions(1).invoiceData.item(1).identifier=37013&receiverOptions(1).invoiceData.item(1).price=1&receiverOptions(1).invoiceData.item(1).itemPrice=1&receiverOptions(1).invoiceData.item(1).itemCount=1&receiverOptions(1).invoiceData.totalTax=0.00&receiverOptions(1).invoiceData.totalShipping=0.00&receiverOptions(1).receiver.email=duncan.wood-vendor%40yahoo.com

    You can see in bold above that shipping isn’t going to the vendor here in the PayPal request. What’s going on here? There must be another spot in the code I’m missing.

    #13745
    Jordan
    Participant

    Tried again but instead this time I divided the total shipping amount amongst all the products in a vendor’s package. See it here: http://pastebin.com/qvhjxU8h

    So, long story short, my first version of the plugin (http://pastebin.com/qF94eyz3) does not work because the PayPal request doesn’t get the proper shipping amounts because of how the software uses two variables that are grouped and not grouped. If I had to guess I’d say it has something to do with me using a static variable to keep track of who has been paid their shipping dues. In my plugin, I’m adding shipping once per package (remember: each package belongs to one vendor/source) so that if the shipping has already been added, it doesn’t get added twice. The function is being called twice which means the 2nd call is probably still using that same static variable, so when it checks to see if it should add shipping to the vendor during the 2nd call it sees that they’ve already been paid and thus you get the right totals the 1st time but not the 2nd. Just a guess. I’m not sure how to go about removing this static variable because how else would I keep track of whether or not a vendor has been paid shipping if it’s being ran twice. I thought about passing that $grouped argument that gets passed in WCV_Vendors::get_vendor_dues_from_order($order, $grouped = true) but that didn’t quite pan out when I tried it.

    I decided to also try and just divide the shipping amount between all products in each package. So $5.75 due to a vendor for 5 items would mean each item would have $1.15 added to it. See it in action here: http://pastebin.com/kQK0Jmuk

    The part that calculates how much to give to each line item is here:

    $vendor_owed_shipping = $data['cost']; // this is their total shipping due for the entire order
    $number_items_pkg = count(explode('|', $data['product_ids'])); // string of a pipe separated array of product IDs being exploded and counted
    $shipping_dues['amount'] = (($vendor_owed_shipping / $number_items_pkg) * $product['qty']); // total shipping owed divided by the number or items in the package multiplied by how many of the item the customer bought

    When running this new change of giving shipping to each product, I get the following response from WCV_Vendors::get_vendor_dues_from_order():

    $receivers = WCV_Vendors::get_vendor_dues_from_order( $order, false ); (not grouped)
    array(2) {
      [1]=> // first chunk of this array is for the store owner. Shipping gets added towards the end…
      array(4) { // each item here is a line item in the order
        [23193]=>
        array(7) { // meta data for each line item in the order
          ["vendor_id"]=>
          int(1)
          ["product_id"]=>
          string(5) "16763"
          ["commission"]=>
          float(39.98)
          ["shipping"]=>
          int(0)
          ["tax"]=>
          int(0)
          ["qty"]=>
          string(1) "2"
          ["total"]=>
          float(39.98)
        }
        [23203]=>
        array(7) {
          ["vendor_id"]=>
          int(1)
          ["product_id"]=>
          string(5) "44223"
          ["commission"]=>
          float(0)
          ["shipping"]=>
          int(0)
          ["tax"]=>
          int(0)
          ["qty"]=>
          string(1) "2"
          ["total"]=>
          float(0)
        }
        [23213]=>
        array(7) {
          ["vendor_id"]=>
          int(1)
          ["product_id"]=>
          string(5) "37013"
          ["commission"]=>
          float(0)
          ["shipping"]=>
          int(0)
          ["tax"]=>
          int(0)
          ["qty"]=>
          string(1) "2"
          ["total"]=>
          float(0)
        }
        [23223]=>
        array(7) {
          ["vendor_id"]=>
          int(1)
          ["product_id"]=>
          string(4) "5737"
          ["commission"]=>
          float(19)
          ["shipping"]=>
          float(-0.95)
          ["tax"]=>
          float(0)
          ["qty"]=>
          string(1) "2"
          ["total"]=>
          float(18.05)
        }
      }
      [109673]=> // now we’re dealing with a vendor…
      array(2) {
        [23203]=>
        array(7) {
          ["vendor_id"]=>
          int(109673)
          ["product_id"]=>
          string(5) "44223"
          ["commission"]=>
          float(75)
          ["shipping"]=>
          float(6.7)
          ["tax"]=>
          int(0)
          ["qty"]=>
          string(1) "2"
          ["total"]=>
          float(81.7)
        }
        [23213]=>
        array(7) {
          ["vendor_id"]=>
          int(109673)
          ["product_id"]=>
          string(5) "37013"
          ["commission"]=>
          float(2)
          ["shipping"]=>
          float(6.7)
          ["tax"]=>
          int(0)
          ["qty"]=>
          string(1) "2"
          ["total"]=>
          float(8.7)
        }
      }
    }
    
    $receivers_two = WCV_Vendors::get_vendor_dues_from_order( $order ); (grouped)
    array(2) {
      [1]=>
      array(6) {
        ["vendor_id"]=>
        int(1)
        ["qty"]=>
        int(8)
        ["commission"]=>
        float(58.98)
        ["total"]=>
        float(58.03)
        ["shipping"]=>
        float(-0.95)
        ["tax"]=>
        float(0)
      }
      [109673]=>
      array(6) {
        ["vendor_id"]=>
        int(109673)
        ["commission"]=>
        float(77)
        ["shipping"]=>
        float(13.4)
        ["tax"]=>
        int(0)
        ["qty"]=>
        int(4)
        ["total"]=>
        float(90.4)
      }
    }

    Notice that the shipping for the vendor is really high while the shipping due to the store is a negative number. Of course, this generates an error from PayPal:
    Error ID: 580022. Invalid request parameter: totalShipping cannot be negative.

    So, that’s where I’m at right now. Hopefully that all made sense. Any glaringly obvious errors? Also, should I even be wasting my time with this if the shipping methods are being updated in the Vendors plugin? Will it accomplish what I’m going for? Will it be ready anytime soon? @digitalchild

    #15303
    Jordan
    Participant

    I feel like I’m just talking to myself here…

    What’s up? Should I wait because Pro is going to solve my problems or do I need to put more effort into this? My workaround almost works, I just can’t wrap my head around the grouped/ungrouped distinction (discussed prior) which is throwing everything else off.

    #15348
    WC Vendors Support
    Participant

    I talk to myself all the time. 🙂 Usually it’s four letter cuss words, though!

    Jordan, grab the latest Pro master off of GitHub and the latest Free master off of GitHub. The shipping system is done, minus some helper stuff. See how that works for ya.

    #15413
    Jordan
    Participant

    I went ahead and did that and from what I can tell this doesn’t accomplish my goal. Again, I’m aiming to use USPS’s shipping calculator to provide rates for packages in a customer’s cart (split by each vendor). I don’t see any indication that Pro supports this when looking at the page found at WP-Admin / WooCommerce > Settings > Vendor Shipping. The “Shipping System” field shows “Flat Rate” and “Country Table Rate” as options, neither of which satisfy the USPS goal.

    #15417
    WC Vendors Support
    Participant

    That’s right, there’s no USPS module, it’s all an assumed flat rate that the vendor enters. For the most part, a general idea of what shipping costs is pretty easy since USPS has flat rates anyway. Getting them “exact” is just a bit more work than we’re up for since not every store would use USPS, let alone UPS or FedEx, and then that doesnt count the 65% of International users of WC Vendors with their own individual countries post plus International carriers. The way we’ve written ours is the “catch all” to accommodate most shipping needs for the majority of admins….

    #15583
    Jordan
    Participant

    I’m a little annoyed because when I brought this up before, you made it seem like this feature was on the way;

    Pro […] will have updated shipping modules that will do all the things you expect and love.

    To which I replied

    It’s good to know that it’s a feature that’s on its way. That’s a relief!

    Maybe you didn’t understand my request clearly or were in a rush, which I would more than understand because there’s always new support threads popping up here and being in software development myself I know what it’s like having 30 things that need to get done at once.

    In response to your last post in this thread:
    With the modifications that I’m proposing, a store could use virtually any WooCommerce compatible shipping method and have their vendors paid during checkout using the amounts calculated during checkout per each vendor. I’m sure there would be some limitations depending on the shipping method used but overall for most use cases I think it would work. I’ve seen this problem pop up in the forums a handful of times so I know people other than myself would benefit from it and I don’t represent a fringe use case. My code is 90% working at this point. I just need help with WCV_Vendors::get_vendor_dues_from_order() because it gets called twice (once grouped and once ungrouped) and I can’t figure out how to handle that 2nd call because I’ve already marked certain vendors as paid by that point so the amount doesn’t get added correctly that 2nd time.

    Again, I am more than willing to compensate you guys for your effort if this is a fringe use case you never planned on doing.

    #15660
    Jamie
    Keymaster

    Hi Jordan,

    Now that I’ve finished the shipping module for pro I can take a look into this and help you get the groups part of the shipping working. You can think of our shipping module more of a hybrid flat rate/country & state rate per product shipping system. As Ben mentioned this will allow people to put in their rates in a simple national/international or country based rates.

    It’s almost impossible to support every shipping module automatically as shipping is calculated at a cart/package level while all our commission is calculated at a product level. This means that for any shipping calculator you’d want to use you’d have to modify the calculator to use different origins based on the vendors store location and then hook into the get_shipping_due to return the shipping for the vendor to be added to commission.

    I’m more than happy to add more actions/filters/order meta data if that will help with your calculations however there is no easy way to support any calculators.

    cheers,

    Jamie.

    #15688
    Jordan
    Participant

    Jamie,

    Good point. I hadn’t thought about the origin zip code as a factor to consider. All of my vendors are located within a hundred miles of my store so it wouldn’t affect us dramatically but that would be a real concern for others.

    It would be much appreciated if you find the time to look into this. I plan on supporting USPS for the foreseeable future so who knows, I might find an open source USPS method and fork it to support WC Vendors for everyone to use.

    #30112
    Dave
    Participant

    What is the status of this discussion? Is there a list of plugins needed and directions to get it going or someone to talk to / hire to make it happen?

    Also I want to use the pro version of wc vendors but use usps for all my vendors.

    I need each vendor to be able to input their ship from zip code either per product or per their store settings and all their products will be calculated based on that location. So a shopping cart may have products shipping from several locations. The shipping fees would be given to each vendors commission.

    Something like this but for wc vendors http://ignitewoo.com/woocommerce-extensions-plugins-themes/woocommerce-usps-drop-shipping-pro/

    #30294
    Vipin Kumar
    Participant

    @compasslocal, I would also love to have it available integrated with WC Vendors pro for http://ignitewoo.com/woocommerce-extensions-plugins-themes/woocommerce-fedex-drop-shipping-pro/ for my store. On my marketplace my vendors are located across the country and i need to pick there pin codes for the products being sold by them.

    Any help is appreciated.


    @GoTeamScotch

    @ben

    #30311
    WC Vendors Support
    Participant

    If you need custom shipping solutions coded up, https://codeable.io

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