I've finally figured out that the module is working at the node level, but that in grid view it isn't. How can I help to get this working in grid view as well, because it's an awesome module that overcomes one of my pet peeves with Ubercart, namely that mixing products that have attributes with those that don't requires you to either display the price twice for products with attributes, or to only display it at the attribute level. Either way confuses customers.

CommentFileSizeAuthor
#9 uc_aac_fixes.diff2.59 KBmikejoconnor

Comments

cyu’s picture

Title: Doesn't update price in grid view » Support for Grid View
Category: bug » feature

I've never tested this module in grid view. I suppose as long as the products are separated out into named divs the module could form_alter the needed javascript in. I'd probably commit a patch that did this without interfering with current functionality.

harrisben’s picture

There is a div surrounding the price for each item in the grid as follows (an example):

<div class="category-grid-products">
<table><tbody><tr><td>
<span class="catalog-grid-title">
<a href="/content/black">Black</a>
</span>
<span class="catalog-grid-image">
<a href="/content/black">
</a>
</span>
<span class="catalog-grid-sell-price">
<div class="uc-price">$8.25</div>
</span>
<div class="add-to-cart"> // contains product attribute options, excluded for the sake of brevity
</div>
</td></tr></tbody></table>
</div>

My javascript knowledge is limited so I don't know if you need something to uniquely identify which price in the grid you will be modifying however because as far as I can see there is nothing that can help you with this. If you need a hand with testing this I would be happy to act as a guinea pig.

jantoine’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Active » Postponed

harrisben,

I have moved this feature request to the new 6.x-2.x branch, as the 6.x-1.x branch will now only be accepting bug fixes. Currently, uc_aac partly works in grid view in that it can update attributes in the add-to-cart form. It can't however identify other product elements because, ubercart does not wrap products with a "node-$nid" identifier. Since by default, ubercart does not support this, I am setting the status of this issue to postponed. I have created #629048: By default, product (node) elements are undistinguishable in a multi-product display against the ubercart project in hopes that they will add support for this, as I see it to be an important issue. When ubercart adds support for this issue, I will take another look at it.

With all that said, you can still get uc_aac to work with the grid view via theming. First make sure you have a node identifier in the form of "node-$nid" that wraps each product. Second, inside the node identifier, elements should have classes that match the product page such as "uc-price-sell", "uc-price-display", etc. With these in place, you should have no problem with uc_aac working on the grid view.

Cheers,

Antoine

jantoine’s picture

Title: Support for Grid View » Support for multi-product displays

Adding a bit more information to this issue.

A duplicate issue was created here: #638264: AAC working badly with multiple products (using radio buttons)

Updated the Ubercart issue here: #629048: By default, product (node) elements are undistinguishable in a multi-product display

Updated the title to correctly reflect the issue.

A possible workaround would be to use the form_alter hook to add the necessary identifier to each product (node) element as the form is being built.

Cheers,

Antoine

jantoine’s picture

Title: Support for multi-product displays » Support for multi-product, views and pages other than the default node page

Another scenario has popped up here: #720648: uc_aac not updating sell price in view. Adjusting the title of the issue accordingly.

Cheers

Antoine

chriscalip’s picture

For people wanting this functionality right now without waiting for patches, this can be pulled off now with the current mix of ubercart, attributes, Ubercart Ajax Attribute Calculations, Ubercart Views.

Here's how i did it.

On the view I added the nid but had it as excluded from display. Then on the Sell Price Views field I had it rewritten as this:

<div id="node-[nid]">
 <div class="product-info product display">[sell_price] </div>
</div>

WORKS! :)

FranCarstens’s picture

Awe-freakin'-some! This works in custom product nodes too!! You are my hero!

chriscalip’s picture

brings a smile in my face.

mikejoconnor’s picture

Title: Support for multi-product, views and pages other than the default node page » Improper form_id check, Support for multi-product, views and pages other than the default node page
Category: feature » bug
Status: Postponed » Needs review
StatusFileSize
new2.59 KB

So this issue can be reduced to two issues.

1. We can not depend on classes outside of the form itself. I.E. this module assumes that the add to cart form is placed within a div.add-to-cart. This is a false assumption. Lines 5-11 and 17-28 resolve this by adding a class to the form itself.

--- uc_aac.js
+++ uc_aac.js
@@ -34,5 +34,5 @@ jQuery.fn.ucAacAttach = function() {
 }
 
 Drupal.behaviors.ucAac = function() {
-  $('.add-to-cart').ucAacAttach();
+  $('.uc-aac-cart').ucAacAttach();
 };
diff --git uc_aac.module uc_aac.module
index 0760955..2fa0b3d 100644
--- uc_aac.module
+++ uc_aac.module
@@ -35,9 +35,11 @@ function uc_aac_menu() {
  * Implementation of hook_form_alter().
  */
 function uc_aac_form_alter(&$form, $form_state, $form_id) {
-  if (strstr($form_id, 'uc_product_add_to_cart_form_')) {
+  if (strstr($form_id, 'uc_product_add_to_cart_form')) {
     static $uc_aac_js = false;
 
+    // Add a class to the cart form. This will allow us to easily identify it for binding ajax stuff.
+    $form['#attributes']['class'] .= ' uc-aac-cart';
     if (!$uc_aac_js) {
       $uc_aac_js = true;
 

Item 2 is a bit more difficult, and not as common. theme_uc_product_add_to_cart() uses two styles of form id's. The standard one is uc_product_add_to_cart_form_[nid], however it can also return uc_product_add_to_cart_form without the appended nid. The remainder of the patch .

Line 20-21 modifies the form name check to be a little more relaxed.
Lines 30-40 add a hidden form field with the nid, removing the need to parse for the nid in the ajax callback(lines 42-53).
Line 55-70 attempts to replace the form using the same form id convention.

I don't know that this resolves all of the issues here, but it should be a step in the right direction.

cyu’s picture

Assigned: Unassigned » cyu
cyu’s picture

Status: Needs review » Fixed

Thanks folks, I've committed this code: http://drupal.org/cvs?commit=393898

In digging on this module I found some issues in d6 FAPI that are currently preventing uc_aac from working on checkbox and radio attributes on pages where multiple products are displayed with the same attributes. The problem exists for select attributes as well (element ids not being unique) but in the case of select attributes uc_aac still works as expected.

#855474: multiple products on one page giving unexpected behavior

I had hoped to get a fix in for that along with this patch, but it is a rare scenario and would be messy to code in d6, so I probably will leave it be until d7 unless somebody else submits a patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ocamp’s picture

hi, sorry i cant get this to work.

Is this supposed to make attributes auto calculate in views?

cyu’s picture

This should be helpful if you'd like to get this working in a view: #624582: Views Integration Example

bellagio’s picture

#6 solution:
It doesn't work with 6.x-1.x-dev.
Works with 6.x-2.x-dev.
Took me a while to figure it out...