Jump to content


in progress

Shortcode For Exchange?

Exchange shortcode

9 replies to this topic

#1 janet hall

janet hall

    Advanced Member

  • Members
  • Others: Toolkit, 3rd Party Exchange Addons
  • PipPipPip
  • 240 posts
  • LocationPort Republic, MD

Posted 06 August 2013 - 01:15 PM

I'm using Exchange for the first time and would like to add the buy now button on a page I've already created. Do we have a shortcode for Exchange products?
Janet Hall, Trainer, Virtual Web Master, Web Developer
Kick Start Web Sites: The Place to Call or Click When You Need Help
We can teach you how or we can do it for you
http://www.kickstartwebsites.com
info@kickstartwebsites.com
410-586-9440
Visit my other sites atJanetLHall.com

#2 Elise Alley

Elise Alley

    iThemes Support

  • Administrators
  • Others: All Plugins, All Themes, Members, Moderators, Toolkit, Webdesign
  • 5,235 posts
  • LocationOklahoma City, OK

Posted 06 August 2013 - 01:23 PM

Hey Janet,

There's not a way to add the payment button to a non-product page.  The product pages do have to be the Exchange page type, so you can't create a page and then add Exchange to it for the individual products.

Let us know if you have any other questions.

Thanks,

Elise

#3 kevinbatdorf

kevinbatdorf

    New Member

  • Members
  • 3 posts

Posted 10 August 2013 - 10:14 AM

Hey Elise,

This is a feature I would really use as well. I would also like to include an add to cart button on the store page, so the customer wont have to load the product page. Is there a way to do this through the API?

I saw this function in the documentation but not sure how populate those variables.

it_exchange_add_cart_product( $cart_product_id, $product );


#4 webweaver

webweaver

    Advanced Member

  • Members
  • Others: Sync
  • PipPipPip
  • 373 posts

Posted 16 May 2014 - 10:21 AM

shortcodes for individual products to be placed on non-shop page would be awesome!

#5 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 29,985 posts

Posted 20 May 2014 - 04:00 PM

@webweaver,

I've worked out a way to add a "buy" button to a WordPress non exchange post or page via a shortcode. It is fairly experimental, some content is hard-coded, but if you want to give it a spin, please do. So this is not an official iThemes Exchange customisation yet.

The assumption is that you know the product ID, and that most other product information will be added in the post. So (currently) it only outputs description, price and the buy now button. In order for this to make sense, it is highly recommended that you add the superwidget to a sidebar, so that the checkout function can be initiated as well. Otherwise, the buy button would be kinda lost.

This is (as far as I'm concerned) still work in progress, but I'm curious to see how/if at all this works for you.

Add the following code at the end of your child theme's functions.php:

/**
* Creates a shortcode to add a product to the cart
*
*/
function my_it_exchange_add_to_cart($atts) {

   extract(shortcode_atts(array(
			"product_id" => null
   ), $atts));

   it_exchange_set_product( $product_id );

	$output = "<div class='my_it_itemdescription'>Item: " . it_exchange( 'product', 'get-description' ) . "</div>";
	$output .= "<div class='my_it_price'>Price: " . it_exchange( 'product', 'get-base-price' ) . "</div>";
	$output .= "<div class='my_it_buy-now'>" .it_exchange( 'product', 'get-purchase-options', array( 'add-to-cart-edit-quantity' => true, 'buy-now-edit-quantity' =>true ) ) . "</div>";

   return $output;
}
add_shortcode( 'add-to-cart', 'my_it_exchange_add_to_cart' );

Then add the following shortcode in your post or page:

[add-to-cart product_id=123]

where 123 is the (WordPress) ID of the product,

Ronald

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#6 strongeagle

strongeagle

    Member

  • Members
  • Others: All Plugins, Exchange - Stripe
  • PipPip
  • 13 posts
  • LocationUK

Posted 18 June 2014 - 01:36 AM

This is exciting, Ronald!  I'm going to try this...but...

Where do I find the product ID?

Thanks,

Valerie

#7 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 29,985 posts

Posted 18 June 2014 - 03:05 AM

Hi Valerie,

the product id is the same as the WordPress post ID. You can find this in the url when you are editing a product for instance, or when you hover over the product in the list of products,

See also: http://codex.wordpress.org/FAQ_Working_with_WordPress#How_do_I_determine_a_Post.2C_Page.2C_Category.2C_Tag.2C_Link.2C_Link_Category.2C_or_User_ID.3F

Ronald

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.


#8 Arlen Nagata

Arlen Nagata

    New Member

  • Members
  • Others: All Plugins
  • 5 posts

Posted 18 June 2014 - 02:06 PM

Thanks Ronald!  

This is amazing!  I'm going to work on adding the product image and title and wrapping it in a div for styling.

#9 Arlen Nagata

Arlen Nagata

    New Member

  • Members
  • Others: All Plugins
  • 5 posts

Posted 18 June 2014 - 02:41 PM

Building on Ronald's code, Here's what I came up with so far. Although I am very new at working with this API.  

This adds a Featured Thumbnail Image, Product Title and basic tags which can be styled.  

/*
* Creates a shortcode to add a product to the cart
*
*/
function my_it_exchange_add_to_cart($atts) {
   extract(shortcode_atts(array(
						"product_id" => null
   ), $atts));
   it_exchange_set_product( $product_id );
	 $output = "<div class='my_it_product_shortcode'><div class='my_it_itemimage'>" . it_exchange( 'product', 'featured-image', array( 'size' => 'thumbnail', 'return' => 'true' ) ) . "</div>";
		$output .= "<div class='my_it_itemdtitle'><h2>" . it_exchange( 'product', 'get-title' ) . "</h2></div>";
		$output .= "<div class='my_it_itemdescription'><b>Description: </b> " . it_exchange( 'product', 'get-description' ) . "</div>";
		$output .= "<div class='my_it_price'>Price: " . it_exchange( 'product', 'get-base-price' ) . "</div>";
		$output .= "<div class='my_it_buy-now'>" .it_exchange( 'product', 'get-purchase-options', array( 'add-to-cart-edit-quantity' => true, 'buy-now-edit-quantity' =>true ) ) . "</div></div>";
   return $output;
}
add_shortcode( 'add-to-cart', 'my_it_exchange_add_to_cart' );


#10 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 29,985 posts

Posted 18 June 2014 - 03:33 PM

excellent!

Join the iThemes Builder Community on Google+.



To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.



When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.




Reply to this Topic


ATTENTION
If this topic is marked RESOLVED or INFORMATION, or if you are NOT experiencing EXACTLY the same issue, please start a new topic to provide the details of your problem. If the solution provided doesn't work for you, you should start a new topic. If you feel this thread contains relevant information, you may include a link to it in your new topic. To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. When posting your question or request on the forum, please be as concise and specific as possible. The shorter and more to the point you can make your request, the better.

For BackupBuddy related issues, be sure to include the status log from your most recent backup.

CLICK HERE to start a new topic in the Exchange ecommerce plugin forum.


  



Also tagged with one or more of these keywords: in progress, Exchange shortcode

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users