
-
AuthorPosts
-
February 1, 2014 at 5:05 pm #218265
I have a client who has invented a game – and that is the only item he will be selling from this website. He wants a “Purchase” button to link to a PayPal account.
Exactly like a “Donate” button … but a “Purchase” button for one item, so I don’t need a whole store. I can do the PayPal part …
How do I put a Purchase button in my header – to the right of my Pages menu?
February 1, 2014 at 7:45 pm #218280Hey Gracezena!
Add this to your functions.php file (at the end):
add_filter( 'wp_nav_menu_items', 'avia_append_paypal', 10, 2 ); function avia_append_paypal ( $items, $args ) { if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu")) { global $avia_config; ob_start(); ?> <!-- Your PayPal HTML goes here --> <img src="_PAYPAL_BUTTON_URL_IMG_" alt=""> <?php $paypal_link = ob_get_clean(); $items .= '<li id="menu-item-paypal" class="noMobile menu-item">'.$paypal_link.'</li>'; } return $items; }
Cheers!
JosueFebruary 4, 2014 at 2:29 am #219089I get this error message … what am I missing?
add_filter( 'wp_nav_menu_items', 'avia_append_paypal', 10, 2 );
function avia_append_paypal ( $items, $args )
{if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu"))
{
global $avia_config;
ob_start();
?><!– <form action=”https://www.paypal.com/cgi-bin/webscr” method=”post” target=”_top”>
<input type=”hidden” name=”cmd” value=”_s-xclick”>
<input type=”hidden” name=”hosted_button_id” value=”EZHM85HZJNUKL”>
<input type=”image” src=”https://www.paypalobjects.com/en_US/i/btn/btn_buynow_SM.gif” border=”0″ name=”submit” alt=”PayPal – The safer, easier way to pay online!”>
</form>–>
<?php
$paypal_link = ob_get_clean();$items .= '<li id="menu-item-paypal" class="noMobile menu-item">'.$paypal_link.'';
}
return $items;
}February 4, 2014 at 2:53 am #219108Hi!
What error message are you getting?
Remove those <!– –> HTML comments around the form.
Best regards,
Josue -
AuthorPosts
- The topic ‘Donate/Purchase button in header’ is closed to new replies.