lundi 28 décembre 2015

if condition for amount in USD $ in rails

My requirement is to show button only if my @order.display_total < $200 so when I have included given code:

- if method.method_type == 'cashondelivery' && @order.display_total < $200
     .form-buttons{"data-hook" => "buttons"}
        = form.hidden_field :cod_pay, :value => true
        = submit_tag "Order Now", :class => 'order-now btn btn-danger'

it gives me error :

NoMethodError - undefined method `<' for #<Spree::Money:0x007ff3d9366490>:

where as @order fetch this:

#<Spree::Order id: 5964, number: "R981938713", item_total: #<BigDecimal:7ff3d2514f78,'0.3843E3',18(18)>, total: #<BigDecimal:7ff3cea3bd20,'0.3843E3',18(18)>, state: "address", adjustment_total: #<BigDecimal:7ff3d25149b0,'0.0',9(18)>, user_id: 1, completed_at: nil, bill_address_id: 24481, ship_address_id: 24482, payment_total: #<BigDecimal:7ff3d25142f8,'0.0',9(18)>, shipping_method_id: nil, shipment_state: nil, payment_state: nil, email: "admin@skinnymint.com", special_instructions: nil, created_at: "2015-12-27 03:45:02", updated_at: "2015-12-28 12:30:34", currency: "USD", last_ip_address: "127.0.0.1", created_by_id: 1, shipment_total: #<BigDecimal:7ff3d251eb68,'0.0',9(18)>, additional_tax_total: #<BigDecimal:7ff3d251ea00,'0.0',9(18)>, promo_total: #<BigDecimal:7ff3d251e7d0,'0.0',9(18)>, channel: "spree", included_tax_total: #<BigDecimal:7ff3d251e5c8,'0.0',9(18)>, item_count: 7, approver_id: nil, approved_at: nil, confirmation_delivered: false, considered_risky: false, guest_token: "aGoCAkyLXJs1oOUp9dS96w", locale: nil, state_lock_version: 0, cod_pay: false>

and @order.display_total = $398.40

Please guide me how to put if condition for this as I am new in spree rails. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire