Support

Home Forums Event Espresso Premium Add "add to card" functionality to widget.pgp

Add "add to card" functionality to widget.pgp

Posted: February 5, 2014 at 1:28 am

Viewing 3 reply threads


Morten Mouritzen

February 5, 2014 at 1:28 am

Hello,

I am trying to add the basic “add to card” functionality to the widget.php.

I already modified that file before, and i made my attempt. But something is missing.

I tried putting this line of code in, but it just changes the page as expected.

id; ?>”>Add to card

How can i add the Add to cart functionality to the widget.php file?


Morten Mouritzen

February 5, 2014 at 1:39 am

I solved it myself 🙂

Here is the code.

<code>			$params = array(
				//REQUIRED, the id of the event that needs to be added to the cart
				&#039;event_id&#039; =&gt; $event-&gt;id,
				//REQUIRED, Anchor of the link, can use text or image
          &#039;anchor&#039; =&gt; __(&quot;Add to Cart&quot;, &#039;event_espresso&#039;), //&#039;anchor&#039; =&gt; &#039;&lt;img src=&quot;&#039; . EVENT_ESPRESSO_PLUGINFULLURL . &#039;images/cart_add.png&quot; /&gt;&#039;,
				//REQUIRED, if not available at this point, use the next line before this array declaration
				// $event_name = get_event_field(&#039;event_name&#039;, EVENTS_DETAIL_TABLE, &#039; WHERE id = &#039; . $event_id);
				&#039;event_name&#039; =&gt; $event-&gt;event_name,
				//OPTIONAL, will place this term before the link
				&#039;separator&#039; =&gt; __(&quot;  &quot;, &#039;event_espresso&#039;)
			);

			$cart_link = event_espresso_cart_link($params);	
			echo $cart_link;</code>


Morten Mouritzen

February 5, 2014 at 1:40 am

<code>&lt;?php
	$params = array(
		//REQUIRED, the id of the event that needs to be added to the cart
		&#039;event_id&#039; =&gt; $event-&gt;id,
		//REQUIRED, Anchor of the link, can use text or image
	&#039;anchor&#039; =&gt; __(&quot;Add to Cart&quot;, &#039;event_espresso&#039;), //&#039;anchor&#039; =&gt; &#039;&lt;img src=&quot;&#039; . EVENT_ESPRESSO_PLUGINFULLURL . &#039;images/cart_add.png&quot; /&gt;&#039;,
		//REQUIRED, if not available at this point, use the next line before this array declaration
		// $event_name = get_event_field(&#039;event_name&#039;, EVENTS_DETAIL_TABLE, &#039; WHERE id = &#039; . $event_id);
		&#039;event_name&#039; =&gt; $event-&gt;event_name,
		//OPTIONAL, will place this term before the link
		&#039;separator&#039; =&gt; __(&quot;  &quot;, &#039;event_espresso&#039;)
	);

	$cart_link = event_espresso_cart_link($params);	
	echo $cart_link;			
?&gt;	</code>


Morten Mouritzen

February 5, 2014 at 1:40 am

oh .. well place delete the double posted answer. I tried to made a better post view of the code.. It failed.

Viewing 3 reply threads

The support post ‘Add "add to card" functionality to widget.pgp’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso