Jump to content


Replying to Shortcode For Exchange?


Post Options

  or Cancel


Topic Summary

wheerani

Posted 30 October 2014 - 04:37 PM

No sweat Ronald...  Thank you for doing what you did.

I guess we will leave it as a mystery why the button is reloading the page (with '/?ite-sw-state=checkout') when clicked but nothing seems to change - like a purchase button or screen showing...

Thanks any way.

Ronald

Posted 30 October 2014 - 04:03 PM

Hi,

unfortunately, currently, this is "the best" I can do given the way Exchange works. I know that the dev's are working on/planning to work on an integrated solution in Exchange, I have no ETA on when this will be implemented though,

Ronald

wheerani

Posted 30 October 2014 - 12:04 PM

Thanks Roland for this shortcode.  Once implemented into exchange fully it will be very handy.

Unfortunately, after adding the code as mentioned to a button on our front page, when clicked the page reloads adding '/?ite-sw-state=checkout' to the url but nothing else changes on the page/buy button...  Any thoughts?

Please note this is a membership item, if that makes any difference.  Also, if possible to just have the stripe window popup when the buy button is clicked that is the desired outcome - instead of having to again press the Purchase button.

Thank you!

Elise Alley

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

craigbrissell

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.

craigbrissell

Posted 21 September 2014 - 07:52 PM

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

singingresults

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

Ronald

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

Ronald

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

craigbrissell

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.

Review the complete topic (launches new window)