Sha256: 0ab9693589d4c2c30b41eb4bb21e6721c1ed0b544edd02c35af4efec21e9af77

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module Workarea
  module Storefront
    class GlobalEController < ApplicationController
      def get_checkout_cart_info
        if checkout_cart_info_params[:countryCode].present? || checkout_cart_info_params[:MerchantGUID].present?
          order.update_attribute(:checkout_started_at, Time.current)
        end

        if checkout_cart_info_params[:IsStockValidation]
          InventoryAdjustment.new(order).tap(&:perform)
        end

        # GlobalE overriding fixed pricing for the order
        #
        if checkout_cart_info_params[:isFixedPriceSupported].present? &&
            checkout_cart_info_params[:isFixedPriceSupported].to_s == "false"
          order.update_attribute(:fixed_pricing, false)
        end

        render json: Workarea::GlobalE::CheckoutCartInfo.new(order).to_json
      end

      private

        def order
          @order ||= Order.find_by(
            global_e_token: checkout_cart_info_params.require(:cartToken)
          )
        end

        def checkout_cart_info_params
          params.permit(
            :cartToken,
            :countryCode,
            :IsStockValidation,
            :MerchantGUID,
            :isFixedPriceSupported
          )
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-global_e-1.3.0 app/controllers/workarea/storefront/global_e_controller.rb
workarea-global_e-1.2.1 app/controllers/workarea/storefront/global_e_controller.rb