Keyword

Payment for items in k2

  • Kran Chi
  • Kran Chi's Avatar Topic Author
  • Visitor
5 years 7 months ago - 5 years 7 months ago #169171 by Kran Chi
Payment for items in k2 was created by Kran Chi
Hello,

I want to add a payment button in k2 item page that make it featured.
So here's the scenario :

1- First user submit the item
2- After the item approved by admin, user can click on the payment button and go to paypal gateway.
3- when the payment done successfully, item will be featured.

I can implement the payment process by plugin but want to know a sample code for :

- showing the button in k2 item page (to fetch item id)
- edit k2_items.featured column in database


Any suggestion will be appreciated .
Last edit: 5 years 7 months ago by Kran Chi. Reason: better typo!
The topic has been locked.
More
5 years 7 months ago #169180 by JoomlaWorks
Replied by JoomlaWorks on topic Payment for items in k2
The K2 Example Plugin is a good starting point. Shows you how to add fields in the K2 item form (and not only) that get rendered in the frontend. This way you could also add your own "featured" flag in the plugin params column in the K2 items table in the DB. There is no need to hack the DB schema.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
The topic has been locked.
  • Kran Chi
  • Kran Chi's Avatar Topic Author
  • Visitor
5 years 7 months ago #169192 by Kran Chi
Replied by Kran Chi on topic Payment for items in k2
Thank you. I will install that.

But for database I didn't mean altering the structure of table. just edit the value. anyway I can check the source codes of k2 to find it.
The topic has been locked.
More
5 years 7 months ago #169206 by JoomlaWorks
Replied by JoomlaWorks on topic Payment for items in k2
You'll be fine. If you need any help with the plugin, just ask.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
The topic has been locked.
  • Kran Chi
  • Kran Chi's Avatar Topic Author
  • Visitor
5 years 7 months ago #169258 by Kran Chi
Replied by Kran Chi on topic Payment for items in k2
Hello again,

I wrote below codes to make a k2 item featured :
// make the k2 item featured
	$db = JFactory::getDbo();
	$query = $db->getQuery(true);
	$fields = array(
		$db->quoteName('featured') . ' = '.'1'
	);
	
	$conditions = array(
	$db->quoteName('id') . ' = '.$item->id
	);
	
	$query->update($db->quoteName('#__k2_items'))->set($fields)->where($conditions);
	$db->setQuery($query);
	$result = $db->execute();

It's working now. but is there a better way?
The topic has been locked.
More
5 years 7 months ago #169270 by JoomlaWorks
Replied by JoomlaWorks on topic Payment for items in k2
Did you place this in a plugin event?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
The topic has been locked.
  • Kran Chi
  • Kran Chi's Avatar Topic Author
  • Visitor
5 years 7 months ago #169281 by Kran Chi
Replied by Kran Chi on topic Payment for items in k2
Yep!
The topic has been locked.
More
5 years 7 months ago #169296 by JoomlaWorks
Replied by JoomlaWorks on topic Payment for items in k2
Which plugin event (duh)? :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
The topic has been locked.
  • Kran Chi
  • Kran Chi's Avatar Topic Author
  • Visitor
5 years 6 months ago #169414 by Kran Chi
Replied by Kran Chi on topic Payment for items in k2
It's in the onK2BeforeDisplayContent
The topic has been locked.

Powered by Kunena Forum