Git Product home page Git Product logo

Comments (3)

dieuit07 avatar dieuit07 commented on May 31, 2024

I try comment code relate to address. No button showing, only image and link popup 'What 's paypal?'

app/views/spree/shared/braintree_vzero/_paypal.js

enableShippingAddress: false,
// shippingAddressOverride: {
//   recipientName: '<%# "#{shipping_address.firstname} #{shipping_address.lastname}" %>',
//   streetAddress: '<%# shipping_address.address1 %>',
//   extendedAddress: '<%# shipping_address.address2 %>',
//   locality: '<%# shipping_address.city %>',
//   countryCodeAlpha2: '<%# shipping_address.country.try(:iso) %>',
//   postalCode: '<%# shipping_address.zipcode %>',
//   region: '<%# shipping_address.state.try(:abbr) %>',
//   phone: '<%# shipping_address.phone %>',
//   editable: false
// },

app/views/spree/braintree_vzero/_paypal_checkout.html.erb

      enableShippingAddress: false,
      enableBillingAddress: false,

from spree_braintree_vzero.

mdavo6 avatar mdavo6 commented on May 31, 2024

@dieuit07 I'm going to assume you are trying to skip the address step where a customer clicks on the 'checkout with paypal' button from the cart page. Is this correct? (The following explanation is assuming this is the case, note that I required a confirmation step in my checkout flow but you may not need this):

  1. Remove requirement for phone number using an address_decorator (apparently Paypal does not pass back a phone number)
Spree::Address.class_eval do
  def require_phone? 
    false
  end
end
  1. Create an order decorator to allow the checkout state to move from 'delivery' to 'confirmation' (note the default remove_transition has been commented out), and create an update payment amount method (or the amount appears blank on the confirmation page).
Spree::Order.class_eval do
  checkout_flow do
    go_to_state :address
    go_to_state :delivery
    go_to_state :payment, if: ->(order) { order.payment_required? }
    go_to_state :confirm, if: ->(order) { order.confirmation_required? }
    go_to_state :complete
    #remove_transition from: :delivery, to: :confirm
  end

  state_machine.before_transition to: :confirm, do: :update_payment_amount
  state_machine.before_transition to: :complete, do: :process_paypal_express_payments

  private

  def update_payment_amount
    return unless paid_with_paypal_express?

    payments.last.update(amount: total)
  end
end
  1. Create an orders_controller_decorator and push the order state to 'delivery' by changing the following line in the process_paypal_express method:
    Change this line:
payment_method.push_order_to_state(current_order, 'address', email)

to

payment_method.push_order_to_state(current_order, 'delivery', email)

Hope this helps!

EDIT: One point I neglected to mention is that you need to add the following line to your 'config/initializers/spree.rb' file:

Spree::Config[:always_include_confirm_step] = true

from spree_braintree_vzero.

dieuit07 avatar dieuit07 commented on May 31, 2024

Thanks @mdavo6 . I will try it soon 👍

from spree_braintree_vzero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.