https://solidus.io logo
Join Slack
Powered by
# support
  • b

    benmorganio

    02/08/2024, 9:57 PM
    Actually, double check the price on the line item.
  • b

    benmorganio

    02/08/2024, 9:57 PM
    Let's validate it's not a buggy presentation of the price.
  • j

    Jacob Penn

    02/08/2024, 9:58 PM
    yeah the line item is somehow where it's getting miffed up -- i checked in the admin on an order with the user though and it is in the model on the line item
  • b

    benmorganio

    02/08/2024, 9:58 PM
    And you cannot recreate locally?
  • j

    Jacob Penn

    02/08/2024, 9:58 PM
    yeah unfortunately not -- i tried manually setting the headers like:
  • j

    Jacob Penn

    02/08/2024, 9:59 PM
    Copy code
    def set_currency
            # session[:currency] = currency_from_headers
            # session[:country] = country_from_headers
            session[:currency] = 'EUR'
            session[:country] = 'DE'
          end
  • j

    Jacob Penn

    02/08/2024, 9:59 PM
    i'll try cloning my production database down quick maybe that'll help
  • b

    benmorganio

    02/08/2024, 9:59 PM
    Do you have a staging setup to test on?
  • b

    benmorganio

    02/08/2024, 9:59 PM
    Yeah, that'll help.
  • b

    benmorganio

    02/08/2024, 10:00 PM
    First thing is I want to validate it's not a display bug. So:
  • b

    benmorganio

    02/08/2024, 10:01 PM
    Copy code
    order = Spree::Order.where(currency: 'EUR').last
    p order
    p order.line_items
  • b

    benmorganio

    02/08/2024, 10:01 PM
    Let's see what's in there.
  • b

    benmorganio

    02/08/2024, 10:02 PM
    Update that scope to an order number you know is effected.
  • j

    Jacob Penn

    02/08/2024, 10:03 PM
    Copy code
    =>
    [#<Spree::LineItem:0x00007efcf2c282b0
      id: 347352,
      variant_id: 54,
      order_id: 283231,
      quantity: 1,
      price: 0.1e4,
      created_at: Thu, 08 Feb 2024 15:41:55.575342000 CST -06:00,
      updated_at: Thu, 08 Feb 2024 15:41:55.974511000 CST -06:00,
      cost_price: nil,
      tax_category_id: 1,
      adjustment_total: 0.0,
      additional_tax_total: 0.0,
      promo_total: 0.0,
      included_tax_total: 0.0,
      stripe_plan_id: nil,
      free_perpetual_trial: false>]
    irb(main):007:0> p o.line_items.first.price.to_f
    1000.0
    => 1000.0
  • b

    benmorganio

    02/08/2024, 10:04 PM
    @Jacob Penn also, how are line items added to the order?
  • j

    Jacob Penn

    02/08/2024, 10:04 PM
    just with the typical populate function
  • j

    Jacob Penn

    02/08/2024, 10:04 PM
    using the regular frontend add to cart code
  • j

    Jacob Penn

    02/08/2024, 10:04 PM
    i've almost got the production DB cloned to my local so maybe i'll be able to reproduce it with that
  • b

    benmorganio

    02/08/2024, 10:05 PM
    Did it come from solidus_starter_frontend?
  • j

    Jacob Penn

    02/08/2024, 10:06 PM
    ah ha -- i was able to make it happen locally after the clone
  • j

    Jacob Penn

    02/08/2024, 10:06 PM
    i'm on the old frontend unfortunately
  • b

    benmorganio

    02/08/2024, 10:07 PM
    For reference on what the new method does: https://github.com/solidusio/solidus/blob/main/core/app/models/spree/order_contents.rb#L37-L53
  • b

    benmorganio

    02/08/2024, 10:08 PM
    Can you paste the code in that you're using to populate?
  • j

    Jacob Penn

    02/08/2024, 10:09 PM
    i'm still on the old populate here:
  • j

    Jacob Penn

    02/08/2024, 10:09 PM
    Copy code
    def populate
          @order = current_order(create_order_if_necessary: true)
          authorize! :update, @order, cookies.signed[:guest_token]
    
          variant  = Spree::Variant.find(params[:variant_id])
          quantity = params[:quantity].present? ? params[:quantity].to_i : 1
    
          binding.pry
    
          # 2,147,483,647 is crazy. See issue <https://github.com/spree/spree/issues/2695>.
          if !quantity.between?(1, 2_147_483_647)
            @order.errors.add(:base, t('spree.please_enter_reasonable_quantity'))
          else
            begin
              @line_item = @order.contents.add(variant, quantity)
            rescue ActiveRecord::RecordInvalid => error
              @order.errors.add(:base, error.record.errors.full_messages.join(", "))
            end
          end
    
          respond_with(@order) do |format|
            format.html do
              if @order.errors.any?
                flash[:error] = @order.errors.full_messages.join(", ")
                redirect_back_or_default(spree.root_path)
                return
              else
                redirect_to cart_path
              end
            end
          end
        end
  • j

    Jacob Penn

    02/08/2024, 10:10 PM
    im trying to find where the price is set though
  • j

    Jacob Penn

    02/08/2024, 10:10 PM
    Copy code
    def add_to_line_item(variant, quantity, options = {})
          binding.pry
          line_item = grab_line_item_by_variant(variant, false, options)
    
          line_item ||= order.line_items.new(
            quantity: 0,
            variant: variant,
            adjustments: [],
          )
    
          line_item.quantity += quantity.to_i
          line_item.options = ActionController::Parameters.new(options).permit(PermittedAttributes.line_item_attributes).to_h
    
          line_item.target_shipment = options[:shipment]
          line_item.save!
          line_item
        end
  • j

    Jacob Penn

    02/08/2024, 10:10 PM
    ^ this bit
  • k

    kennyadsl

    02/08/2024, 10:10 PM
    Are you sure you are not passing the price in the options params when populating the order?
  • j

    Jacob Penn

    02/08/2024, 10:10 PM
    lets see
1...3536373839Latest