medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.99k stars 2.49k forks source link

Where is shipment based on weight #4598

Closed spacewalkingninja closed 3 months ago

spacewalkingninja commented 1 year ago

Bug report

make it like in prestashop//thirtybees cant add shipping method that calculates based on weight, I want to add my carrier and it should read the products weights in the basket and check the table of pricings for this weight basicallty smthujn like: --|1kg|1.1kg-5kg| ... UK|1€|2€|... FR |2€|3.14€|.... PT |0€| 1€|....

Describe the bug

Prestashop can do this medusajs which is better CANT do this. Make medusaJS CHAD TRULLY BETTER!

System information

Medusa version (including plugins): Node.js version: Database: Operating system: Browser (if relevant):

Steps to reproduce the behavior

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen

Screenshots

If applicable, add screenshots to help explain your problem

Code snippets

If applicable, add code samples to help explain your problem

Additional context

Add any other context about the problem here

ShivamJoker commented 1 year ago

I am also looking for the same option. Any help from the medusa team would be appreciated.

WilliamTraoreee commented 1 year ago

I'm in the same situation, I'm looking for this but don't find any solution.

spacewalkingninja commented 1 year ago

Hello I make this plugin already problem is the people who maintain medusajs do not talk to mi!!! Very bad indeed! Anybody who need this module please talk to me, or I will have to start selling this plugin because the people who make medusajs do not deserve this plugin. @olivermrbl why u not talk to mi?

SGFGOV commented 1 year ago

Have you published this plugin yet?

Best Regards Govind Diwakar

On Thu, 17 Aug, 2023, 20:37 spacewalkingninja, @.***> wrote:

Hello I make this plugin already problem is the people who maintain medusajs do not talk to mi!!! Very bad indeed! Anybody who need this module please talk to me, or I will have to start selling this plugin because the people who make medusajs do not deserve this plugin. @olivermrbl https://github.com/olivermrbl why u not talk to mi?

— Reply to this email directly, view it on GitHub https://github.com/medusajs/medusa/issues/4598#issuecomment-1682451149, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXEQJHBUV4XV2B6LDE33PS3XVYXRNANCNFSM6AAAAAA2V55E7I . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

This message (including any attachments) may contain confidential, proprietary, privileged and/or private information. The information is intended to be for the use of the individual or entity designated above. If you are not the intended recipient of this message, please notify the sender immediately, and delete the message and any attachments. Any disclosure, reproduction, distribution or other use of this message or any attachments by an individual or entity other than the intended recipient is prohibited.   

spacewalkingninja commented 1 year ago

For hakerz like me here is how you make it work: go to backend folder on your virtual machine where you run the dev version for production. Go to folder backend/src/services/ CREATE FILE "ship-methods.ts"

Paste in the following code:::


class ShipMethodsService extends FulfillmentService {
  static identifier = "shipping-options"

  constructor() {
    super()
  }

  getFulfillmentOptions() {
    return [
      {
        id: "nacex-fulfillment",
      },
      {
        id: "nacex-fulfillment-return",
        is_return: true,
      },
    ]
  }

  validateFulfillmentData(_, data, cart) {
    return data
  }

  validateOption(data) {
    return true
  }

  canCalculate() {
    return true
  }

  calculatePrice(optionData, data, cart) {
    //console.log(optionData)
    //console.log(data)
    //console.log(cart)
    var totalWeight = 0;
    for(let i=0; i < cart.items.length; i++)
    {
    var itm = cart.items[i]
    console.log(itm.variant)
    //console.log(itm.variant.weight)
    //console.log(itm.variant.product.weight)
    if(!isNaN(itm.variant.weight)) { 
      totalWeight += itm.variant.weight }
    if(!isNaN(itm.variant.product.weight)) { 
      totalWeight += itm.variant.product.weight }
    //totalWeight += itm.variant.weight
    }
    var st = cart.subtotal / 100;

    console.log("weight is:"+totalWeight)
    console.log("Cart total is:"+st)

    var weightRanges = [[501, 516], [5000, 601], [10000, 645], [15000, 873], [20000, 1025], [25000, 1328], [30000, 1702], [35000, 1872], [40000, 2290], [45000, 2645]]

    var shippingExtra = 0;
    if(500 < totalWeight)
    {
      if(st > 60 && st < 120)
      {
          shippingExtra += -490; 
      }
      if(st > 120 && st < 180)
      {
          shippingExtra += -525; 
      }
      if(st > 180 && st < 240)
      {
          shippingExtra += -710; 
      }
      if(st > 240 && st < 300)
      {
          shippingExtra += -835;
      }
      if(st > 300 && st < 360)
      {
          shippingExtra += -1080;
      }
      if(st > 320)
      {
          shippingExtra += -1385;
      }
    }
    var shipPrice = 0;
    for (let i=0; i<weightRanges.length; i++)
    {
      if (weightRanges[i][0] > totalWeight)
      {
        shipPrice += weightRanges[i][1]
        break;
      }
    }

    //var clc = cart.items.length * 1000 + shippingExtra
    var clc = shipPrice + shippingExtra
    console.log(clc)
    return clc
    //  throw Error("Manual Fulfillment service cannot calculatePrice")
  }

  createOrder() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  createReturn() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  createFulfillment() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  cancelFulfillment() {
    return Promise.resolve({})
  }

  retrieveDocuments() {
    return Promise.resolve([])
  }
}

export default ShipMethodsService

where the variable weigRanges is [[MAX_WEIGHT, PRICE], [MAX_WEIGHT2, PRICE2], [WEIGHT_ETC, PRICE_ETC],...]

then go to settings in admin penel the click on the regions

image

then select zi region zen klik zi "edit region details" image

and adds the fullfilemn profivers in the fullfilment provicers thing image

because they dont wantta kall it simply "SHIPPING METHODS" but absstract with fulfilment things and only then you can click save and close and then right beneath in SHIPPING OPTIONS image

click ADD OPTION

image

add the name of the shipping option you programmed and click price type = calculated, shipping profile=default_shipping_profile and fuillfilment method is the one you created for the region with the module we add to the systems

spacewalkingninja commented 1 year ago

Have you published this plugin yet? Best Regards Govind Diwakar On Thu, 17 Aug, 2023, 20:37 spacewalkingninja, @.> wrote: Hello I make this plugin already problem is the people who maintain medusajs do not talk to mi!!! Very bad indeed! Anybody who need this module please talk to me, or I will have to start selling this plugin because the people who make medusajs do not deserve this plugin. @olivermrbl https://github.com/olivermrbl why u not talk to mi? — Reply to this email directly, view it on GitHub <#4598 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXEQJHBUV4XV2B6LDE33PS3XVYXRNANCNFSM6AAAAAA2V55E7I . You are receiving this because you are subscribed to this thread.Message ID: @.> -- This message (including any attachments) may contain confidential, proprietary, privileged and/or private information. The information is intended to be for the use of the individual or entity designated above. If you are not the intended recipient of this message, please notify the sender immediately, and delete the message and any attachments. Any disclosure, reproduction, distribution or other use of this message or any attachments by an individual or entity other than the intended recipient is prohibited.

hey check this here

spacewalkingninja commented 1 year ago

@olivermrbl YOU ARE HEREBY ORDERED TO FIX THIS ISSUE FOR USSR! THANK YOU FOR SUPPORTING FREE SOFTWARE COMMUNITY AS I ORDER! have a gud ivning

Kushal-starr commented 9 months ago

Hello I make this plugin already problem is the people who maintain medusajs do not talk to mi!!! Very bad indeed! Anybody who need this module please talk to me, or I will have to start selling this plugin because the people who make medusajs do not deserve this plugin. @olivermrbl why u not talk to mi?

For hakerz like me here is how you make it work: go to backend folder on your virtual machine where you run the dev version for production. Go to folder backend/src/services/ CREATE FILE "ship-methods.ts"

Paste in the following code:::


class ShipMethodsService extends FulfillmentService {
  static identifier = "shipping-options"

  constructor() {
    super()
  }

  getFulfillmentOptions() {
    return [
      {
        id: "nacex-fulfillment",
      },
      {
        id: "nacex-fulfillment-return",
        is_return: true,
      },
    ]
  }

  validateFulfillmentData(_, data, cart) {
    return data
  }

  validateOption(data) {
    return true
  }

  canCalculate() {
    return true
  }

  calculatePrice(optionData, data, cart) {
    //console.log(optionData)
    //console.log(data)
    //console.log(cart)
    var totalWeight = 0;
    for(let i=0; i < cart.items.length; i++)
    {
    var itm = cart.items[i]
    console.log(itm.variant)
    //console.log(itm.variant.weight)
    //console.log(itm.variant.product.weight)
    if(!isNaN(itm.variant.weight)) { 
      totalWeight += itm.variant.weight }
    if(!isNaN(itm.variant.product.weight)) { 
      totalWeight += itm.variant.product.weight }
    //totalWeight += itm.variant.weight
    }
    var st = cart.subtotal / 100;

    console.log("weight is:"+totalWeight)
    console.log("Cart total is:"+st)

    var weightRanges = [[501, 516], [5000, 601], [10000, 645], [15000, 873], [20000, 1025], [25000, 1328], [30000, 1702], [35000, 1872], [40000, 2290], [45000, 2645]]

    var shippingExtra = 0;
    if(500 < totalWeight)
    {
      if(st > 60 && st < 120)
      {
          shippingExtra += -490; 
      }
      if(st > 120 && st < 180)
      {
          shippingExtra += -525; 
      }
      if(st > 180 && st < 240)
      {
          shippingExtra += -710; 
      }
      if(st > 240 && st < 300)
      {
          shippingExtra += -835;
      }
      if(st > 300 && st < 360)
      {
          shippingExtra += -1080;
      }
      if(st > 320)
      {
          shippingExtra += -1385;
      }
    }
    var shipPrice = 0;
    for (let i=0; i<weightRanges.length; i++)
    {
      if (weightRanges[i][0] > totalWeight)
      {
        shipPrice += weightRanges[i][1]
        break;
      }
    }

    //var clc = cart.items.length * 1000 + shippingExtra
    var clc = shipPrice + shippingExtra
    console.log(clc)
    return clc
    //  throw Error("Manual Fulfillment service cannot calculatePrice")
  }

  createOrder() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  createReturn() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  createFulfillment() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  cancelFulfillment() {
    return Promise.resolve({})
  }

  retrieveDocuments() {
    return Promise.resolve([])
  }
}

export default ShipMethodsService

where the variable weigRanges is [[MAX_WEIGHT, PRICE], [MAX_WEIGHT2, PRICE2], [WEIGHT_ETC, PRICE_ETC],...]

then go to settings in admin penel the click on the regions

image

then select zi region zen klik zi "edit region details" image

and adds the fullfilemn profivers in the fullfilment provicers thing image

because they dont wantta kall it simply "SHIPPING METHODS" but absstract with fulfilment things and only then you can click save and close and then right beneath in SHIPPING OPTIONS image

click ADD OPTION

image

add the name of the shipping option you programmed and click price type = calculated, shipping profile=default_shipping_profile and fuillfilment method is the one you created for the region with the module we add to the systems

Hi @spacewalkingninja I had some doubts on this can we connect on this?

Kushal-starr commented 9 months ago

Hello I make this plugin already problem is the people who maintain medusajs do not talk to mi!!! Very bad indeed! Anybody who need this module please talk to me, or I will have to start selling this plugin because the people who make medusajs do not deserve this plugin. @olivermrbl why u not talk to mi?

Hey!, I need to know more about this plugin. Could you please help on that.

Kushal-starr commented 7 months ago

For hakerz like me here is how you make it work: go to backend folder on your virtual machine where you run the dev version for production. Go to folder backend/src/services/ CREATE FILE "ship-methods.ts"

Paste in the following code:::


class ShipMethodsService extends FulfillmentService {
  static identifier = "shipping-options"

  constructor() {
    super()
  }

  getFulfillmentOptions() {
    return [
      {
        id: "nacex-fulfillment",
      },
      {
        id: "nacex-fulfillment-return",
        is_return: true,
      },
    ]
  }

  validateFulfillmentData(_, data, cart) {
    return data
  }

  validateOption(data) {
    return true
  }

  canCalculate() {
    return true
  }

  calculatePrice(optionData, data, cart) {
    //console.log(optionData)
    //console.log(data)
    //console.log(cart)
    var totalWeight = 0;
    for(let i=0; i < cart.items.length; i++)
    {
    var itm = cart.items[i]
    console.log(itm.variant)
    //console.log(itm.variant.weight)
    //console.log(itm.variant.product.weight)
    if(!isNaN(itm.variant.weight)) { 
      totalWeight += itm.variant.weight }
    if(!isNaN(itm.variant.product.weight)) { 
      totalWeight += itm.variant.product.weight }
    //totalWeight += itm.variant.weight
    }
    var st = cart.subtotal / 100;

    console.log("weight is:"+totalWeight)
    console.log("Cart total is:"+st)

    var weightRanges = [[501, 516], [5000, 601], [10000, 645], [15000, 873], [20000, 1025], [25000, 1328], [30000, 1702], [35000, 1872], [40000, 2290], [45000, 2645]]

    var shippingExtra = 0;
    if(500 < totalWeight)
    {
      if(st > 60 && st < 120)
      {
          shippingExtra += -490; 
      }
      if(st > 120 && st < 180)
      {
          shippingExtra += -525; 
      }
      if(st > 180 && st < 240)
      {
          shippingExtra += -710; 
      }
      if(st > 240 && st < 300)
      {
          shippingExtra += -835;
      }
      if(st > 300 && st < 360)
      {
          shippingExtra += -1080;
      }
      if(st > 320)
      {
          shippingExtra += -1385;
      }
    }
    var shipPrice = 0;
    for (let i=0; i<weightRanges.length; i++)
    {
      if (weightRanges[i][0] > totalWeight)
      {
        shipPrice += weightRanges[i][1]
        break;
      }
    }

    //var clc = cart.items.length * 1000 + shippingExtra
    var clc = shipPrice + shippingExtra
    console.log(clc)
    return clc
    //  throw Error("Manual Fulfillment service cannot calculatePrice")
  }

  createOrder() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  createReturn() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  createFulfillment() {
    // No data is being sent anywhere
    return Promise.resolve({})
  }

  cancelFulfillment() {
    return Promise.resolve({})
  }

  retrieveDocuments() {
    return Promise.resolve([])
  }
}

export default ShipMethodsService

where the variable weigRanges is [[MAX_WEIGHT, PRICE], [MAX_WEIGHT2, PRICE2], [WEIGHT_ETC, PRICE_ETC],...]

then go to settings in admin penel the click on the regions

image

then select zi region zen klik zi "edit region details" image

and adds the fullfilemn profivers in the fullfilment provicers thing image

because they dont wantta kall it simply "SHIPPING METHODS" but absstract with fulfilment things and only then you can click save and close and then right beneath in SHIPPING OPTIONS image

click ADD OPTION

image

add the name of the shipping option you programmed and click price type = calculated, shipping profile=default_shipping_profile and fuillfilment method is the one you created for the region with the module we add to the systems

@spacewalkingninja while going thru this, like when I checkout -> and under delivery its showing the option for the available shipping-methods for the region, but issue is for the calculated one its not showing the price at that only. It should be visible.

Screenshot 2024-03-04 at 3 52 24 PM
sradevski commented 3 months ago

Hey, thanks for the report! Since v2 brought a lot of architectural and API changes on the backend, we will be closing this ticket since it no longer applies to our new setup, or the issue has already been fixed. If you are still facing issues with v1, please open a new ticket and we will address it as soon as possible. Thanks! 🙏