wp-e-commerce / WP-e-Commerce

WP eCommerce - The most popular independent eCommerce platform for WordPress
https://wpecommerce.org
GNU General Public License v2.0
215 stars 217 forks source link

Add variations to the cart in TEv2 #2353

Open jbeales opened 6 years ago

jbeales commented 6 years ago

When using TEv2, and adding a product with variations to the cart, the variation information does not get saved, only the root product gets added to the cart.

The mostly-correct variation information is shown in the "Added to Cart" dialog box, but the cart total is shown as zero, and if the variation modifies the price of the product that modification is not displayed, (the price of the root product is displayed), however, when I get to the Checkout page only the root product is in the cart.

JustinSainton commented 6 years ago

Confirmed that this is a regression from #2295. I imagine when we're syncing the product model, we need to be passing the expected variation data if it exists. Though it seems we've made some effort to do that...so....hmmm. This is where I beg @jtsternberg to take a look 😂

jbeales commented 6 years ago

Additional comment, (probably related, but it could be dealt with in a separate issue): When selecting a variation on the product page, we the price is no longer updated like it used to be in TEv1.

mihaijoldis commented 6 years ago

Just my thoughts on this.

re the additional comment, i believe its not working at the moment because the new theme engine is not ajaxified yet.

On the first issue, i found it confusing to see the issue cause i know for a fact the variations are working on our website wpecommerce.org and are visible on the checkout page.

Did some digging and i found (and tested locally and on wpec.org) that with this line of code added in the themes functions.php file disables the notifications BUT also fixes the issue reported in this issue

add_filter( 'wpsc_do_cart_notifications', '__return_false' );

Enabling the filter seems to "break" it as john has reported.

jtsternberg commented 6 years ago

Re: product-dom-to-model.js, we really need to do away with that hack, and instead pass any product data as a proper model to the JS. This means that whenever a product is fetched on the frontend, we need to queue it as a model that should be localized for JS. This would be far more reliable than trying to parse from the dom. We would need to tie the products to those models. IIRC, I did add a product id data attribute to most of the products output, so that would definitely be the best way to map them.

jtsternberg commented 6 years ago

The other option is do the model fetching via JS/ajax whenever a product is interacted with (via adding to cart).