Shortcode for price converts to PayPal button
-
I have a price shortcode like this:
[price sku="123EVR"]
that I want to convert into a PaylPal add-to-cart button.The code in my functions.php file looks like this:
// Add Shortcode function price_shortcode( $atts , $content = null ) { $sku = $atts['sku']; // Code $p = $wpdb->get_row("SELECT prodPrice, prodName FROM products WHERE SKU ='$sku' LIMIT 1"); return '<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <p style="TEXT-ALIGN: left"> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="business" value="[email protected]" /> <input type="hidden" name="add" value="1" /> <input type="hidden" name="item_name" value="'.$p->prodName.'" /> <input type="hidden" name="item_number" value="'.$sku.'" /> <input type="hidden" name="amount" value="'.$p->prodPrice.'" /> <input type="hidden" name="no_shipping" value="2" /> <input type="hidden" name="currency_code" value="USD" /> <input type="image" border="0" name="submit" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" alt="Make payments with PayPal - it\'s fast, free and secure!" /></p> </form>'; } add_shortcode('price', 'price_shortcode');
It seems to error out on the DB query, probably from not getting a value for $sku.
What am I missing here? This is not a full plugin, just a work-around for site I’m moving into WordPress.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Shortcode for price converts to PayPal button’ is closed to new replies.