Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Workarounds to using this in Vue

I am attempting to create a PayPal checkout order on my Vue site. I am currently passing two props to the component as well as two data objects

  props: {
    price: Number,
    shipping: Number,
  },
  data() {
    return {quantity: 1, switches: 'red'}
  },

I am referencing these four variables in my code as this.price, this.shipping etc. I have confirmed these are all valid

I am attempting to access these inside a method but this is being over-ridden and all four of these are undefined.

I still don't quite understand this, but I was under the impression that using an arrow function as I have done should stop this from changing. Is this not the case?

Code

   await paypal.Buttons({
      style: {
        layout: 'vertical',
        color: 'black',
        shape: 'pill',
      },
      createOrder: (data, actions) => {
        return actions.order.create({
          purchase_units: [{
            amount: {
              currency_code: "USD",
              value: ((this.price + this.shipping) * this.quantity).toString(),
              breakdown: {
                item_total: {  /* Required when including the `items` array */
                  currency_code: "USD",
                  value: this.price.toString()
                },
                shipping: {
                  currency_code: "USD",
                  value: this.shipping.toString()
                }
              }
            },
            items: [
              {
                name: "First Product Name", /* Shows within upper-right dropdown during payment approval */
                description: "Optional descriptive text..", /* Item details will also be in the completed paypal.com transaction view */
                unit_amount: {
                  currency_code: "USD",
                  value: this.price.toString()
                },
                quantity: this.quantity.toString
              },
            ]
          }]
        });
      },
    }).render('#paypal-button-container')
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!