Quote

We're also available for Custom Joomla Development

Hire us now
MAdmin1995 on Friday, November 06 2015, 02:57 PM

Dealicious and k2store?

Hi guys,

I have a question on the new template that you guys released. I see its using the default article component that comes with joomla, but with a previous template that I bought it used K2, and with K2 I used K2store as the checkout module. Is there a way to change the article manager from the default one to k2 so my checkout module will work with the k2 articles? The reason for this is because we only have limited online merchants in South Africa and K2Store only supports the one I'm using.

Would highly appreciate the help.
Kind Regards
Martin Pretorius
Resolved
The discussion has been resolved.

Accepted Answer

  • Replied by admin on Saturday, November 07 2015, 01:58 PM
    Ok, open this file
    ../plugins/content/dealicious/forms/content.xml

    at line 63 before the </fieldset> tag add this code :
    <field
         name="k2store_id"
         type="text"
         label="K2 Store ID"
    />


    At this point you will see a new field called K2 Store ID in the Deal Settings tab when you add a new article, to let you to add the K2store ID manually.

    Next, re-open the /templates/dealicious/html/com_content/article/dealicious.php file and change the previous code I suggested to this one :

    if ($ending->toUnix() > $today->toUnix()) : 
    $k2store_id = $attributes->k2store_id;
    ?>
         <a href="/<?php echo JRoute::_('/index.php?option=com_k2store&view=mycart&task=add&product_id='.$k2store_id); ?>" class="j2store-cart-button tp-deal-addtocart_btn btn btn-primary uk-button-large uk-width-1-1 mt15 mb15 pt10 pb10">
    Add to cart
    </a>
                    <?php endif; ?>

    Please post rating at the Joomla! Extensions Directory - http://extensions.joomla.org/profile/profile/details/264
     
  • Replied by admin on Saturday, November 07 2015, 02:06 AM · Hide· #1
    Hi Martin,
    Unfortunately to change the article from default joomla content component to K2 will need a major code changes.
    As you need to use K2store, I think it should not be a problem to use j2store, as both of these component are developed by same developer so they should have similar features.
    Please post rating at the Joomla! Extensions Directory - http://extensions.joomla.org/profile/profile/details/264
  •  
  • Replied by MAdmin1995 on Saturday, November 07 2015, 06:44 AM · Hide· #2
    Hi again

    The problem is that J2store only has support for certain online merchants, the one I use is VCS, and K2store has this plugin ready but with J2store there is no such luck. What I was thinking of doing is maybe using the nonumber article anywhere (pro) and integrate the 4 components, so that the K2 content shows in the article, and the add to cart button refers to k2 store but still uses j2store as its implemented by the article component. Any advise on how I could link the k2store to the add to cart button? Or what code I need to change? I have the following link that allows me to add items to the cart:
    <a href="/<?php echo JRoute::_('/index.php?option=com_k2store&view=mycart&task=add&product_id='.$custom[1]->value); ?>">

    This is the code I used in the previous deal plaza template that you guys sold, now can I make it work in the dealicious template with the add to cart button?
  •  
  • Replied by admin on Saturday, November 07 2015, 12:08 PM · Hide· #3
    Ah I see. It's strange to see J2store doesn't support VCS, have you asked them why they don't support it?
    <a href="/<?php echo JRoute::_('/index.php?option=com_k2store&view=mycart&task=add&product_id='.$custom[1]->value); ?>">

    This is the code I used in the previous deal plaza template that you guys sold, now can I make it work in the dealicious template with the add to cart button?

    Ok, please open this file : ... /templates/dealicious/html/com_content/article/dealicious.php
    at lines 301 to 304 you will see these codes :

    if ($ending->toUnix() > $today->toUnix()) {
    					echo $this->item->event->afterDisplayContent;
    				}
    				?>


    try to change that code to this :

    if ($ending->toUnix() > $today->toUnix()) : ?>
    					<a href="/<?php echo JRoute::_('/index.php?option=com_k2store&view=mycart&task=add&product_id='.$custom[1]->value); ?>" class="j2store-cart-button tp-deal-addtocart_btn btn btn-primary uk-button-large uk-width-1-1 mt15 mb15 pt10 pb10">Add to cart</a>
    				<?php endif; ?>
    Please post rating at the Joomla! Extensions Directory - http://extensions.joomla.org/profile/profile/details/264
  •  
  • Replied by MAdmin1995 on Saturday, November 07 2015, 12:48 PM · Hide· #4
    Okay, so whats happening now is the add to cart button gets the link right, but I cant seem to get it to get the K2 ID, do you maybe know of some way of getting the custom field or the item ID from the k2 item that gets displayed via the articles anywhere component? I tried using the following code but doesnt return anything.

    <?php
    			//	{article k2:current}{/article}
    				$K2Itemid = JRequest::getInt('id');
    			$db = JFactory::getDBO();
    			$db->setQuery("SELECT title FROM #__k2_items WHERE id = ".$K2Itemid );
    			$K2Catid = $db->loadResult(); 
    				// Hide add to cart button when deal is expired
    				$today    = JFactory::getDate();
    				if ($ending->toUnix() > $today->toUnix()) : ?>
                        <a href="/<?php echo JRoute::_('/index.php?option=com_k2store&view=mycart&task=add&product_id='.$K2Catid); ?>" class="j2store-cart-button tp-deal-addtocart_btn btn btn-primary uk-button-large uk-width-1-1 mt15 mb15 pt10 pb10">Add to cart</a>
                    <?php endif; ?>
    
  •  
  • Replied by MAdmin1995 on Saturday, November 07 2015, 06:14 PM · Hide· #5
    That got it working! Ahh thank you so much for your help. Actually the best support I have received so far out of any of the templates and extensions I have bought. Really appreciate what you guys do. Super impressed.

    One last question though, is there a way to get the same animation thing that gives you the green bar above the add to cart button as it does with j2store? I know I need to change the /components/com_k2store/controllers/mycart.php file, because I changed it to work with the link otherwise I just got a JSON response. its not important but it looks really nice and really fits in with the design. Thanks again for everything so far though!
  •  
  • Replied by admin on Sunday, November 08 2015, 03:00 AM · Hide· #6
    Hi Martin,
    Glad it helps ;)
    Regarding the green bar, I'm not familiar with K2store code but I believe the most effective way to achieve that same animation is by creating a content plugin that is fired on afterDisplayContent event, just like j2store did.
    Please post rating at the Joomla! Extensions Directory - http://extensions.joomla.org/profile/profile/details/264
  •  
  • Replied by MAdmin1995 on Sunday, November 08 2015, 07:59 AM · Hide· #7
    Okay, are you perhaps able to tell me where I could find this code from the j2store for afterDisplayContent?
  •  
  •  
    Replied by admin on Sunday, November 08 2015, 11:13 AM · Hide· #8
    J2store handles this button through plugin content->j2store.
    The files are under this folder ../plugins/content/j2store

    And, if you are willing to use plugin, you need to put back the original code again at lines 301-304 back to
    if ($ending->toUnix() > $today->toUnix()) {
       echo $this->item->event->afterDisplayContent;
       }
    ?>
    Please post rating at the Joomla! Extensions Directory - http://extensions.joomla.org/profile/profile/details/264
Your Response
Please login first in order for you to submit comments