Recently I've wanted to do an online shop via PayPal and have done single products really well, However recently I wanted to do a cart system and one problem I now have is setting a PayPal checkout price to one of the php total var. I know about IPN's but I need to set the price before the redirect to the PayPal checkout.
Any help will be immensely appreciated!
Since you don't share any code for your checkout, here are the best options:
1) Demo pattern of front-end that uses client-side code only
2) Demo pattern of front-end that calls server-side endpoints, which would need to implement order creation and capture APIs.
In the case of #1 the amount is set in the client-side JS code, so your PHP code would need to output that code with the variable set in the appropriate place.
In the case of #2 the code will call an endpoint on your server, which would need to call the PayPal API to create a payment object with the amount set, and return that payment object's unique orderID to the checkout in the XHR response body so that it can proceed.