News:

Looking for documentation? Take a look on our wiki

Main Menu

Propose a patch in cart.php helper

Started by wumen, May 28, 2013, 07:24:44 AM

Previous topic - Next topic

wumen

Hi all.

I am using Virtuemart 2.0.20b fresh install with the standard template and with Joomla! 2.5.11

I have developed a plugin, working and tested by a friend in a real life shop, now:

1) I would like to submit an enhance to the code because the returning state from pluging it seems like to be unclear; I have tried to download the source from svn to propose a patch but it gives me this error:
svn: REPORT of '/svn/virtuemart/!svn/vcc/default': Could not read chunk delimiter: Secure connection truncated (https://dev.virtuemart.net)

2) I would like to add a hook to plugins in cart for the remove action, same issue as previous point.

Thank you for your assistance
----------------
Check out our custom VM plugin: Locking
[url="http://www.wumen.biz/software/virtuemart-plugin-locking-products/"]http://www.wumen.biz/software/virtuemart-plugin-locking-products/[/url]

Milbo

http://dev.virtuemart.net/projects/virtuemart/wiki/Setting_up_a_Development_Environment

Explain EXACT what you want, there are already 150 triggers. You wanna add here and there a trigger calling a process which is using a lot triggers already. Please explain very closely and create a svn patch so that I can diff your suggested changes.
Should I fix your bug, please support the VirtueMart project and become a [url=http://extensions.virtuemart.net/support/virtuemart-supporter-membership-detail]member[/url]
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

PRO

I think he means for his plugin
http://www.wumen.biz/software/virtuemart-plugin-locking-products/


His plugin changes stock as soon as a product is added to cart & goes back in stock when its deleted from cart.

I think thats already working for 2.1 right?

wumen

#3
Hi all,

The solution I have developed is working for the 2.0.20b version, I have checked out and modified the trunk repository in my own local copy (a lot fo disconnection downloading, outputing the error I have mentioned in the previous post); in branches I can not find any 2.1 version, please PRO, where I can find this source?

I refer to the cart.php helper (components/com_virtuemart/helpers/cart.php), at line 454 in trunk I see this function:

function removeProductCart
----
        /**
         * Remove a product from the cart
         *
         * @author RolandD
         * @param array $cart_id the cart IDs to remove from the cart
         * @access public
         */
        public function removeProductCart($prod_id=0) {
                // Check for cart IDs
                if (empty($prod_id))
                $prod_id = JRequest::getVar('cart_virtuemart_product_id');
                unset($this->products[$prod_id]);

                $this->setCartIntoSession();
                return true;
        }
----

this function has got no hook for plugins, as far as can see, while the previous function "add" has, at least in the   2.0.20b , in the trunk the hook in  addToCart commented up (new system for hooking plugins?)

Here is the patch but maybe I am late, because development is gone further, but if this is true, where I can find updated sources and informations to not bore the forum with my questions and proposal?

------------------ cut here ------------------
Index: virtuemart/components/com_virtuemart/helpers/cart.php
===================================================================
--- virtuemart/components/com_virtuemart/helpers/cart.php       (revision 6940)
+++ virtuemart/components/com_virtuemart/helpers/cart.php       (working copy)
@@ -456,6 +456,11 @@
                if (empty($prod_id))
                $prod_id = JRequest::getInt('cart_virtuemart_product_id');
                if(isset($this->cartProductsData[$prod_id])){
+                       // hook for plugin action "remove from cart"
+                       if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
+                       JPluginHelper::importPlugin('vmcustom');
+                       $dispatcher = JDispatcher::getInstance();
+                       $addToCartReturnValues = $dispatcher->trigger('plgVmOnRemoveFromCart',array(&$prod_id));
                        unset($this->cartProductsData[$prod_id]);

                        $this->setCartIntoSession();

------------------ cut here ------------------


Thank you for your help in advance,
Best regards!
----------------
Check out our custom VM plugin: Locking
[url="http://www.wumen.biz/software/virtuemart-plugin-locking-products/"]http://www.wumen.biz/software/virtuemart-plugin-locking-products/[/url]

jenkinhill

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Milbo

Trigger is added. But why the $prod_id as "linked"?
Should I fix your bug, please support the VirtueMart project and become a [url=http://extensions.virtuemart.net/support/virtuemart-supporter-membership-detail]member[/url]
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

GJC Web Design

Hi,

am using this plgVmOnRemoveFromCart trigger in a plugin but as written never seems to fire.

if(isset($this->cartProductsData[$prod_id])){
// hook for plugin action "remove from cart"
if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
JPluginHelper::importPlugin('vmcustom');
$dispatcher = JDispatcher::getInstance();
$addToCartReturnValues = $dispatcher->trigger('plgVmOnRemoveFromCart',array($this,$prod_id));
unset($this->cartProductsData[$prod_id]);
}


the if(isset($this->cartProductsData[$prod_id])){ is always empty on my install...

works fine if I comment this out...

what is $this->cartProductsData[$prod_id]?

Cheers
GJC Web Design
VirtueMart and Joomla Developers - php developers [url="https://www.gjcwebdesign.com"]https://www.gjcwebdesign.com[/url]
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
[url="https://extensions.joomla.org/profile/profile/details/67210"]https://extensions.joomla.org/profile/profile/details/67210[/url]
Contact for any VirtueMart or Joomla development & customisation