{"record":{"id":"7b16330861710143","repo":"spree/spree","slug":"spree-order-disassociate-user-is-deprecated-and","errorCode":null,"errorMessage":"Spree::Order#disassociate_user! is deprecated and will be removed in Spree 6.1. Use #disassociate_customer! instead.","messagePattern":"Spree::Order#disassociate_user! is deprecated and will be removed in Spree 6\\.1\\. Use #disassociate_customer! instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spree/core/app/models/spree/order.rb","lineNumber":529,"sourceCode":"    def associate_customer!(customer, override_email = true)\n      Spree.cart_associate_service.call(guest_cart: self, customer: customer, override_email: override_email)\n    end\n\n    # @deprecated Use {#associate_customer!}; removed in 6.1.\n    def associate_user!(user, override_email = true)\n      Spree::Deprecation.warn('Spree::Order#associate_user! is deprecated and will be removed in Spree 6.1. Use #associate_customer! instead.')\n      associate_customer!(user, override_email)\n    end\n\n    def disassociate_customer!\n      nullified_attributes = ASSOCIATED_CUSTOMER_ATTRIBUTES.index_with(nil)\n\n      update!(nullified_attributes)\n    end\n\n    # @deprecated Use {#disassociate_customer!}; removed in 6.1.\n    def disassociate_user!\n      Spree::Deprecation.warn('Spree::Order#disassociate_user! is deprecated and will be removed in Spree 6.1. Use #disassociate_customer! instead.')\n      disassociate_customer!\n    end\n\n    def quantity_of(variant, options = {})\n      line_item = find_line_item_by_variant(variant, options)\n      line_item ? line_item.quantity : 0\n    end\n\n    def find_line_item_by_variant(variant, options = {})\n      line_items.detect do |line_item|\n        line_item.variant_id == variant.id &&\n          Spree.cart_compare_line_items_service.new.call(order: self, line_item: line_item, options: options).value\n      end\n    end\n\n    # Re-estimates tax through the configured provider (writes TaxLine rows\n    # with replace-all semantics).\n    def create_tax_charge!","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/spree/spree/blob/06bf66a8684b9de03210bbb2ddc8c1f5ba522fa2/spree/core/app/models/spree/order.rb#L511-L547","documentation":"Part of the User-to-Customer rename: Spree::Order#disassociate_user! warns and forwards to disassociate_customer!, which nulls ASSOCIATED_CUSTOMER_ATTRIBUTES (customer_id, email, bill_address_id, ship_address_id) in a single update!. The shell is removed in 6.1.","triggerScenarios":"GDPR/anonymization rake tasks and guest-checkout cleanup code calling order.disassociate_user! — the pre-6.0 method name for detaching the buyer record from an order.","commonSituations":"Post-upgrade data-protection tooling; extensions that detach users from orders after export; store credit / PII scrubbers written against 5.x naming.","solutions":["Replace order.disassociate_user! with order.disassociate_customer!.","Use Spree.customer_class (never Spree::User directly) in the surrounding code, per platform-auth conventions.","For full GDPR workflows, prefer the dedicated export/anonymization surface rather than hand-rolled attribute nulling.","Grep tasks and jobs: rg \"disassociate_user\" app lib."],"exampleFix":"# before\norder.disassociate_user!\n\n# after\norder.disassociate_customer!","handlingStrategy":"validation","validationCode":"# One-off audit of anonymization tasks\n# rg \"disassociate_user\" app lib --type ruby","typeGuard":"# Works across Spree 5.x and 6.x\nif order.respond_to?(:disassociate_customer!)\n  order.disassociate_customer!\nelse\n  order.disassociate_user!\nend","tryCatchPattern":null,"preventionTips":["Use Spree.customer_class instead of Spree::User in surrounding code so the rename stays mechanical.","Cover anonymization tasks with their own specs — they run rarely and miss deprecation noise in CI.","Prefer dedicated GDPR export/anonymization tooling over hand-rolled attribute nulling."],"tags":["spree","deprecation","ruby","orders","customers","rename","gdpr"],"backgroundTag":"deprecated-api-usage","analyzedSha":"06bf66a8684b9de03210bbb2ddc8c1f5ba522fa2","analyzedAt":"2026-08-21T14:59:48.125Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}