add to cart button not working in gk4

Ecommerce design Joomla template to start your online business with VirtueMart and additional eshop features.
GK User
Thu Apr 11, 2013 4:37 pm
tha add to cart button works in the k2 categories and item details, but it doesn't work in the front, inside the mod_news_pro_gk4

the Firefox error console says:
Timestamp: 04/11/2013 11:01:36 AM
Error: form.task is undefined
Source File: http://www.pidetumovil.com/tienda/media ... k2store.js
Line: 210.

other than that it simply does nothing no matter how many times you click it.
I have all the products in the k2 store. shop is http://www.technostationus.com

I am online and waiting ask me and I will send you logins and passwords.
User avatar
Fresh Boarder

teitbite
Thu Apr 11, 2013 7:14 pm
Hi

Please send me an access to joomla panel and ftp. Pleas check if You are using the latest version of the module.
User avatar
Moderator

GK User
Thu Apr 11, 2013 11:01 pm
Done, sent you a PM
waiting for a solution.
BTW I am a paid subscriptor so I do have support.
please don't put me in the back burner.

Also sent you email .
User avatar
Fresh Boarder

teitbite
Fri Apr 12, 2013 1:55 pm
Hi

Sorry I could not solve it. For me it looks like there is a totally different K2store version than module is supporting. I've spend half of the night following code and send it to programmers right after going to sleep. Will let You know when they answer.
User avatar
Moderator

GK User
Fri Apr 12, 2013 3:07 pm
teitbite wrote:Hi For me it looks like there is a totally different K2store version than module is supporting.

could it be because I purchased k2store pro? I could remove it and install the regular one back again?
User avatar
Fresh Boarder

GK User
Fri Apr 12, 2013 3:25 pm
I gave you full access so feel free to uninstall reinstall whatever you feel like.
User avatar
Fresh Boarder

teitbite
Sat Apr 13, 2013 7:51 am
Hi

I was right. It wasn't working because of differences between K2store version. Luckily Dziudek found the easiest solution:

As I see the problem is casued by fact that NSP generates in the submit the following onclick:

Code: Select all
k2storeAddToCart( 'index.php?option=com_k2store&view=mycart&Itemid=99', 'addtocart', document.adminForm_68, true, 'Processing' );


and it should be:

Code: Select all
k2storeAddToCart('addtocart', document.adminForm_68, true, 'Processing' );

User avatar
Moderator

GK User
Sun Apr 14, 2013 2:22 am
teitbite wrote:Hi

I was right. It wasn't working because of differences between K2store version. Luckily Dziudek found the easiest solution:

As I see the problem is casued by fact that NSP generates in the submit the following onclick:

Code: Select all
k2storeAddToCart( 'index.php?option=com_k2store&view=mycart&Itemid=99', 'addtocart', document.adminForm_68, true, 'Processing' );


and it should be:

Code: Select all
k2storeAddToCart('addtocart', document.adminForm_68, true, 'Processing' );




Wow you are awesome! you deserve a bonus.

but I still dont unfderstand. how did you fix it what changes did you make? what should I do If I have that same issue ever again in some other site.
User avatar
Fresh Boarder

teitbite
Sun Apr 14, 2013 10:53 am
Hi

It wasn't me but Dziudek from programmers. The fix was needed because in Pro version of K2store a script adding to cart got changed and requires 1 parameter less, so all I've done following Dziudek instruction was to edit NSP's file where K2store part is created and removed this one extra parameter.
User avatar
Moderator

GK User
Sun Apr 14, 2013 3:24 pm
Hi

I have the exact same problem, can you tell me which file to edit.

Thanks
User avatar
Fresh Boarder

teitbite
Mon Apr 15, 2013 11:04 am
Hi

The file is: /modules/mod_news_pro_gk4/tmpl/layout.parts.php code is in last function of this file called store_k2().
User avatar
Moderator

GK User
Mon Apr 15, 2013 1:35 pm
That's weird, I don't have any code that looks like that. I have the latest version of GK4 and the latest version of K2 Store but not the Pro version.
All My Add To Cart Buttons are totally inactive as you can see here http://kevflint.com/mouldstop/ & here http://kevflint.com/mouldstop/index.php ... Itemid=545

I can give you full access if needed

Here is the code I have in layout.parts.php

Code: Select all
   // K2Store block generator

   function store_k2($config, $news_id, $plugins, $k2store_params) {
      //
      if($config['k2store_support'] == 1 && ($config['k2store_show_cart'] == 1 || $config['k2store_add_to_cart'] == 1 || $config['k2store_price'] == 1)) {
         $formName = 'adminForm_'.$news_id;
            $action = 'index.php?option=com_k2store&view=mycart&Itemid='.$k2store_params->get('itemid');
            if(strpos($plugins, 'k2storeitem_price') !== false) {
            $plugins = json_decode($plugins);
             if($plugins->k2storeitem_price) {
                $uri = JURI::getInstance();
                $k2store_currency = $k2store_currency_after = $k2store_currency_before = '';
                    $onclick = "k2storeAddToCart( '".$action."', 'addtocart', document.".$formName.", true, '".JText::_( 'Processing' )."' );";
                    if($k2store_params !== 0) {
                        $k2store_currency = '<span>' . $k2store_params->get('currency') . '</span>';
                        if($config['k2store_currency_place'] == 'after') {
                            $k2store_currency_after = $k2store_currency;
                            $k2store_currency_before = '';
                        } else {
                            $k2store_currency_after = '';
                            $k2store_currency_before = $k2store_currency;
                        }
                    }

                $code = '<div class="nspK2store"><form id="'.$formName.'" name="'.$formName.'" action="'.$action.'" method="post" class="adminform" enctype="multipart/form-data" >';
                    $code .= '<input type="hidden" name="product_id" value="'.$news_id.'"/>';
                    $code .= '<input type="hidden" id="task" name="task" value="" />';
                    $code .= JHTML::_( 'form.token' );
                    $code .= '<input type="hidden" name="return" value="'.base64_encode( JUri::getInstance()->toString() ).'" />';



                if($config['k2store_price'] == 1 ) {
                    $text_item_price = ($config['k2store_price_text'] == 1) ? '<strong>' . JText::_('MOD_NEWS_PRO_GK4_K2STORE_ITEM_PRICE') . '</strong>' : '';
                   $code .= '<span class="nspK2storePrice">' . $text_item_price . $k2store_currency_before . $plugins->k2storeitem_price . $k2store_currency_after . '</span>';
                    }
                if($config['k2store_add_to_cart'] == 1 ) {
                        $code .= '<input onclick="'.$onclick.'" value="'.JText::_('MOD_NEWS_PRO_GK4_K2STORE_ADD').'" type="button" class="addcart button" /></form>';
                }
                if($config['k2store_show_cart'] == 1 ) {
                   $code .= '<input type="button" onclick="window.location = \''.'index.php?option=com_k2store&amp;view=mycart\'" value="'. JText::_('MOD_NEWS_PRO_GK4_K2STORE_SHOW') .'" />';
                }
                $code .= '</form></div>';
                return $code;
            } else {
                return '';
            }
         } else {
            return '';
         }
      } else {
         return '';
      }
   }
       
}
User avatar
Fresh Boarder

GK User
Mon Apr 15, 2013 6:25 pm
Hi
Is anyone going to help with this, I am a paid subscriber and have been for two years, considering this is the only time I have needed support I expected a lot better than this.
User avatar
Fresh Boarder

teitbite
Tue Apr 16, 2013 3:36 pm
Hi

I can see the mentioned code. Here is how it looks in the file:

Code: Select all
$onclick = "k2storeAddToCart( '".$action."', 'addtocart', document.".$formName.", true, '".JText::_( 'Processing' )."' );";


all You need to do is to replace it with:

Code: Select all
$onclick = "k2storeAddToCart( 'addtocart', document.".$formName.", true, '".JText::_( 'Processing' )."' );";
User avatar
Moderator

GK User
Tue Apr 16, 2013 9:03 pm
Hi

Thanks for the help but I had already given that a try and it didn't work, not to worry I have now changed to RedShop and the GK4 module is working perfectly with that.
User avatar
Fresh Boarder

teitbite
Wed Apr 17, 2013 4:51 pm
Hi

Than I believe it was a javascript conflict and not the problem discussed here. Anyway if it's working than I believe it's fine.
User avatar
Moderator


cron