uc_ajax_cart includes a file 'uc_module_add_to_cart.php' which has implementations of hook_add_to_cart() using the namespaces of other modules (uc_stock and uc_attribute). Should these modules ever implement this hook, they will conflict with uc_ajax_cart due to redefinition of the function. uc_ajax_cart should instead move the code from these functions to its own namespace, uc_ajax_cart_add_to_cart().
However, the stock management portion of uc_ajax_cart_add_to_cart() should be considered for removal in my opinion, as it's out of scope for this module. Users should install something like uc_out_of_stock to prevent out of stock products from begin ordered if they want this, as not all want to prevent customers from ordering out of stock products. See #954272: Cannot add out of stock items to cart. As well, note that the current implementation is not completely functional; db_affected_rows() on SELECT operations is database vendor-sepecific and only guaranteed to work on INSERT, UPDATE and DELETE operations. A COUNT query, or checking if db_fetch_object() returned FALSE, should be used instead to verify if any rows were returned.
uc_cart_links has an upstream issue about the required attributes being added to cart bug: #398000: Cart links don't check attributes or options on their products. When the patches there get committed we could remove uc_ajax_cart_add_to_cart() entirely from the codebase.
Comment | File | Size | Author |
---|---|---|---|
#1 | uc_ajax_cart-namespace_violations-1437798-1.patch | 3.15 KB | stewart.adam |
Comments
Comment #1
stewart.adam CreditAttribution: stewart.adam commentedAttached patch makes changes mentioned in above post, removing the uc_stock_add_to_cart() hook and moving the uc_attribute_add_to_cart() hook to ajax_cart_add_to_cart().
Comment #2
stewart.adam CreditAttribution: stewart.adam commentedCommitted.