• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Payments Plugin for Stripe

Stripe payment plugins for your WordPress site

  • Home
  • Documentation
  • Addons
  • Login
    • Sign In
    • Edit Profile
    • Terms & Conditions
    • My Downloads
    • License Key
  • Support
    • Support Forum
    • Forum Search
    • Forum Login
    • Forum Registration
    • Email Support for Customers
  • Contact Us
  • Show Search
Hide Search
You are here: Home / Replies /

Reply To: include product price in short code

· ·

Home › Forums › Stripe Payments Plugin › include product price in short code › Reply To: include product price in short code

May 4, 2019 at 2:30 am #2066
alecmyers
Participant

OK, I figured out what’s going on. You do all the arithmetic twice: once in class-shortcode-asp.php to create the button and form, and then do it all again (reading the price from the database a second time) in process_ipn.php.

I suppose that stops anyone spoofing their own price in the <form>.

So to get the option of [asp_product id=”196″ price=”200″] to work I:

a) send the custom price into get_button_code_new_method( $data ) by adding
685: if (isset($atts[‘price’])) { //ARM20190503
$data[‘customPrice’] = $atts[‘price’];
}

and then
b) spoof the “user set amount” feature by adding a (hidden) field with name ‘stripeAmount’
802: if (isset($data[‘customPrice’])) { //ARM20190503
$data[‘amount’] = $data[‘customPrice’];
error_log($data[‘price’]);
$output .= “<input type=’hidden’ name=’stripeAmount’ value='” . $data[‘customPrice’] . “‘ >”;
}

Now when process_ipn.php is run the field with that name triggers the //Custom amount conditional on 216, as if the customer had entered the amount themselves.

Can you think of a neater way to do this? It’s a bit ‘hacky’.

Primary Sidebar

Featured Addons and Extensions

  • Subscription Payments Addon
  • Additional Custom Fields
  • Secure Downloads Addon
  • Apple Pay, Google Pay, Afterpay

Addon Bundle

Stripe Payments Addon Bundle

A Simple & Lightweight Plugin

Our Philosophy with the Plugin

Support Links

  • Support Forum
  • Support Contact

Search

Copyright © 2025 | Stripe Plugins | A member of the Tips and Tricks HQ family.