Jump to content


Replying to Shortcode For Exchange?


Post Options

  or Cancel


Topic Summary

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.

singingresults

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.

Ronald

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

brandstaruk

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

Review the complete topic (launches new window)