Chapters
35 Chapters
|
3:22:53
|
This course is archived!
This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.5.9, <7.4
Subscribe to download the code!Compatible PHP versions: >=5.5.9, <7.4
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
30.
Coupons! Adding the Form
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses an older version of Symfony of the stripe-php SDK. The majority of the concepts are still valid, though there *are* differences. We've done our best to add notes & comments that describe these changes.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.5.9, <7.4",
"symfony/symfony": "3.1.*", // v3.1.10
"doctrine/orm": "^2.5", // v2.7.2
"doctrine/doctrine-bundle": "^1.6", // 1.6.8
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
"symfony/swiftmailer-bundle": "^2.3", // v2.6.2
"symfony/monolog-bundle": "^2.8", // v2.12.1
"symfony/polyfill-apcu": "^1.0", // v1.3.0
"sensio/distribution-bundle": "^5.0", // v5.0.22
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.26
"incenteev/composer-parameter-handler": "^2.0", // v2.1.2
"friendsofsymfony/user-bundle": "~2.0.1", // v2.0.1
"stof/doctrine-extensions-bundle": "^1.2", // v1.2.2
"stripe/stripe-php": "^3.15", // v3.23.0
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.2.1
"phpunit/phpunit": "^5.5", // 5.7.20
"composer/package-versions-deprecated": "^1.11" // 1.11.99
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.4
"symfony/phpunit-bridge": "^3.0", // v3.3.0
"hautelook/alice-bundle": "^1.3", // v1.4.1
"doctrine/data-fixtures": "^1.2" // v1.2.2
}
}
11 Comments
Yo :)
It would be really handy if a user could remove a product from the cart :)
my cart looks like this: https://imgur.com/a/H6Y6l
now when someone clicks on the x the product should be removed from the cart and the cart should be updated.
my template looks like this:
https://imgur.com/a/H6Y6l
and i started the javascript like this:
i dont know how to send a request to the server and then remove the product or subscription.
a hint for me?
Thanks for anything :)
Hey Blueblazer!
Nice idea, definitely an user will find it helpful
You need two things here, one in your template for sending an AJAX to the server, and a Route in your controller, for handling that request
If you are using Jquery you can use $.ajax() method for seding that request, like this:
Yep, you can use twig inside javascript for simplifying some things, and you only have to adjust that path and product id
Controller:
You can read more about Jquery AJAX here:
http://api.jquery.com/jquery.ajax/
Cheers!
thanks :)
but how should the removeProduct function look like? :P
Hey Blueblazer,
Sorry! I forgot about that method :p
Your implementation looks fine to me, but I think this way may be faster
Products are only updated if the item was found, if it wasn't found you might want to throw an exception because it shouldn't happen
Cheers!
thanks you are awasome :)
but now i get this nasty error: http://imgur.com/a/hU9Kx why does it not recognice the product variable, because it is existing?
Hey Blueblazer172 ,
Please, ensure you're passing "product" variable in all places where you render "order/checkout.html.twig" template - I bet you just missed it somewhere.
Cheers!
yeah my problem is passing the variable to the template, but how can i if the user hasn't selected something.
i tried like this in ordercontroller.php:
and the getProductId() funtion in the shoppingcart.php:
but then i get this error:
Unable to guess how to get a Doctrine instance from the request information for parameter "product".
Hmm, looks like you are mixing some things:
- You shouldn't need to pass the shopping cart to the template, only the products
- Instead of asking for product ID to the shopping cart, you can ask it directly to the product itself
- And if the user hasn't selected anything, then he can't remove anything :)
I hope this makes sense to you :)
Have a nice day!
Hey Blueblazer172
As Victor said, you might have forgotten to pass "product" variable to the template
Have a nice day!
currently my 2 functions in the shoppingcart look like this:
"Houston: no signs of life"
Start the conversation!