0

I'm trying to create a custom Zoo element based on the Quick2Cart element, but I'm realizing that there's a reason I'm not a programmer.

The quick2cart guys have helped a little bit by giving me this snippet:

function getitemid($product_id,$client)
{
    $db = JFactory::getDBO();
    $query = "SELECT `item_id` FROM `#__kart_items`  where `product_id`=".(int)$product_id. " AND parent='$client'";
    $db->setQuery($query);
    $result = $db->loadResult();
    return $result;
}

But I can't quite figure out how to write the element so it renders. All I really want is for the element to check to see if the item is for sale (meaning, it's set up in Quick2cart and is considered a product). If so, I want to display a little "Buy it!" badge that links to the zoo item.

The current Quick2Cart Zoo element has lots of extra stuff in it so I can't simply duplicate it or I'd end up with issues in the edit screen of the zoo item. I don't really want any interface at all for the element. All I really want is an "if it's a product, show this" kind of thing.

0

The TechJoomla guys helped me a bit with this. It could probably still be cleaned up, but it checks for the item and if the Quick2Cart item Id isn't empty and it's a zoo item (so we don't accidentally check for another type of item), it displays a little badge that links to the zoo item.

Building the element itself is based on this document: [Create A Custom Element][1]

in the php file here's what I ended up with:

        <?php

class ElementQtc_available extends Element {

    public function edit() {
    }

    public function render($params = array()) {

    }

    public function hasValue($product_id,$client) 
    {
    $db = JFactory::getDBO();
    $query = "SELECT `item_id` FROM `#__kart_items` where parent='com_zoo' AND `product_id`=".$this->_item->id. "";
    $db->setQuery($query);
    $forsale = $db->loadResult();
    if (!empty($forsale)) 
    {
    print "<div class='buyit'><a href=" .$this->app->route->item($this->_item). ">Buy It!</a></div>";
    }

    }
    }

  [1]: http://yootheme.com/zoo/documentation/developers/create-a-custom-element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.