Jump to content


Welcome to the forum:

Welcome to the iThemes, PluginBuddy and WebDesign.com forum. We've created several tutorial video's to help you get you started with using the forum, please check them out!

Also take note of the forum guidelines.


Support hours:

Our moderators actively respond to forum support requests during normal business hours which are Monday-Friday, 8am - 5pm Central Standard Time, typically within one business day. Although some moderators choose to work during the weekends, we can not guarantee immediate attention to your requests. Thanks for understanding.

What is included with support:

Premium support includes theme/plugin issues such as: bugs encountered under normal operation, how to use basic features, basic WordPress help, and basic help with customization (meaning we point you to resources and will help in more depth as time allows). More information.

in progress

Shortcode For Exchange?

Exchange shortcode

23 replies to this topic

#1 overhall263

overhall263

    Advanced Member

  • Members
  • Others: Toolkit, 3rd Party Exchange Addons
  • PipPipPip
  • 245 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,729 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
  • Others: Exchange - Stripe
  • 8 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
  • 374 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
  • 30,850 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
  • 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
  • 30,850 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 mrarlen

mrarlen

    New Member

  • Members
  • Others: All Plugins, Sync
  • 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 mrarlen

mrarlen

    New Member

  • Members
  • Others: All Plugins, Sync
  • 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
  • 30,850 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.


#11 brandstaruk

brandstaruk

    New Member

  • Members
  • Others: BackupBuddy, Premium Exchange Addon
  • 3 posts
  • LocationSussex, England

Posted 27 August 2014 - 06:38 AM

Hi All,

I hope it is ok to ask a question re the code suggested above here as opposed to creating a new post.  

The get-purchase-options in the line of code
$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;
Is there a way to limit that to just show Add to Cart?

Many thanks,

Graham

#12 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 30,850 posts

Posted 01 September 2014 - 01:36 PM

Hi Graham,

setting the "buy now edit quantity" bit to false should do the trick, but I've not tested that. Give that a try and let us know,

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.


#13 singingresults

singingresults

    New Member

  • Members
  • 6 posts

Posted 18 September 2014 - 02:08 AM

I tried adding to my child theme as describes.

Leaves me with a blank white site. everything gone.

i started from scratch with a trivial theme and no additions in the child except the noted functions.php code.

#14 craigbrissell

craigbrissell

    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 232 posts
  • LocationCape Cod, MA

Posted 18 September 2014 - 03:39 PM

View PostRonald, on 20 May 2014 - 04:00 PM, said:

@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
Hi Ronald... this is great help for me. However, I have couple questions.... How do I get rid of the word "item" above the product.... Page is http://alibixclothing.com
Also, any advice on how to change the color of the buy now and add to cart buttons?

Thanks so much.

#15 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 30,850 posts

Posted 18 September 2014 - 04:28 PM

View PostRobertsing, on 18 September 2014 - 02:08 AM, said:

I tried adding to my child theme as describes.

Leaves me with a blank white site. everything gone.

i started from scratch with a trivial theme and no additions in the child except the noted functions.php code.

Hi,

did you add the code inside php tags? So after an opening <?php and before any closing ?>

If so, can you add the code and then share the entire functions.php in a pastebin (http://pastebin.com/) and send me the link to that pastebin?

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.


#16 Ronald

Ronald

    Forum Admin

  • Administrators
  • Others: All Plugins, All Themes, Moderators, Webdesign
  • 30,850 posts

Posted 18 September 2014 - 04:34 PM

@Craig,

item can be found in this line:

$output = "<div class='my_it_itemdescription'>Item: " . it_exchange( 'product', 'get-description' ) . "</div>";

You can use css to change the color and style of the buttons. Use Firebug to inspect the code, and you can override the css by adding the appropriate css at the end of your child themes stylesheet style.css (as that is where the button inherits the styling from), see image:

Posted Image

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.


#17 singingresults

singingresults

    New Member

  • Members
  • 6 posts

Posted 19 September 2014 - 03:49 PM

Hi Craig... out the door for the weekend, so a quick reply...

I used the last code as noted... and was wrapped in <?php and before any closing ?>... nothing else in the file.  Stephen


<?php
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' );
?>

#18 craigbrissell

craigbrissell

    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 232 posts
  • LocationCape Cod, MA

Posted 21 September 2014 - 07:52 PM

Thanks Guys very much for your help. I really appreciate it.

#19 craigbrissell

craigbrissell

    Advanced Member

  • Members
  • Others: Toolkit
  • PipPipPip
  • 232 posts
  • LocationCape Cod, MA

Posted 26 September 2014 - 04:28 PM

Hi Again... @Ronald or anyone else who may have time to help. Can you please help me with the code to turn Buy now button to Green with white font, sign me up button to Orange with Black Font and "add to cart" button changed to Amazon Yellow with black font... Please? I will really really appreciate it. Thanks in Advance.

#20 Elise Alley

Elise Alley

    iThemes Support

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

Posted 26 September 2014 - 04:32 PM

Hi Craig,

Can you please start a new post for this.  We'd be happy to help you out, but it's unrelated to the original post and it helps to keep the threads to one topic.

When you create your new post, please be sure to include a link to your site.

Thanks,

Elise



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