WooCommerce: How can I add a certain product to the cart and redirect to the cart from a non-shop page?

You can create “add to cart” links for WooCommerce using this pattern on simple links:

http://example.com/cart/?add-to-cart=<product ID>&quantity=<number of quantity>

This example will work with simple products.
If you want to use products with variations you need to add some more values to the URL like:

http://example.com/cart/?add-to-cart=123&variation_id=456&attribute_pa_colour=black

If you enter the slug of the cart page in this url, here: /cart/, it should redirect to the cart.

To add a product to the cart without redirecting:

http://example.com/?add-to-cart=<product ID>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)