Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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?

    #218280

    Hey 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!
    Josue

    #219089

    I 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&#8221; 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&#8221; 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;
    }

    #219108

    Hi!

    What error message are you getting?

    Remove those <!– –> HTML comments around the form.

    Best regards,
    Josue

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Donate/Purchase button in header’ is closed to new replies.