[Events +] Payment localization, PayPal button

The 'Buy now' gif for payment via PayPal is hardcoded to 'https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif' in 'class_eab_template.php'. Is it a way to either use language function to get an image for the correct language? Or a way to select PayPal button from gallery?

  • Dimitris

    Hello espsjurs

    First of all I moved this thread from Features & Feedback (which should be used mostly for requesting new features and sharing feedback about our products) to Support forums.
    For similar requests, please do visit this link https://premium.wpmudev.org/hub/support/#get-support and select "Technical Support".

    Having said that, on the issue you're dealing with, there's a filter already in place, that you can use in order to change the actual HTML markup. :wink:
    Please try to add the following code in a new MU plugin file, like
    wp-content/mu-plugins/my-events-pp-form.php
    (just create the /mu-plugins/ folder, if it doesn't exist already)

    <?php
    function my_get_payment_forms ($content) {
      global $blog_id, $current_user;
      $event = ($post instanceof Eab_EventModel) ? $post : new Eab_EventModel($post);
    
      $booking_id = $event->get_user_booking_id();
      $data = Eab_Options::get_instance();
    
      $content = '';
    
      if( trim( $data->get_option('paypal_email') ) != '' ) {
    
        $content .= $data->get_option('paypal_sandbox')
          ? '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">'
          : '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">'
        ;
        $content .= '<input type="hidden" name="business" value="' . $data->get_option('paypal_email') . '" />';
        $content .= '<input type="hidden" name="item_name" value="' . esc_attr($event->get_title()) . '" />';
        $content .= '<input type="hidden" name="item_number" value="' . $event->get_id() . '" />';
        $content .= '<input type="hidden" name="notify_url" value="' .
          admin_url('admin-ajax.php?action=eab_paypal_ipn&blog_id=' . $blog_id . '&booking_id=' . $booking_id) .
        '" />';
        $content .= '<input type="hidden" name="amount" value="' . $event->get_price()  .'" />';
        $content .= '<input type="hidden" name="return" value="' . get_permalink($event->get_id()) . '?paypal_processing=1" />';
        $content .= '<input type="hidden" name="currency_code" value="' . $data->get_option('currency') . '">';
        $content .= '<input type="hidden" name="cmd" value="_xclick" />';
    
        // Add multiple tickets
        $extra_attributes = '';
        $extra_attributes = apply_filters('eab-payment-paypal_tickets-extra_attributes', $extra_attributes, $event->get_id(), $booking_id);
        $content .= '' .// '<a href="#buy-tickets" class="eab-buy_tickets-trigger" style="display:none">' . __('Buy tickets', Eab_EventsHub::TEXT_DOMAIN) . '</a>' .
          sprintf(
            //'<p class="eab-buy_tickets-target">' . __('I want to buy %s ticket(s)', Eab_EventsHub::TEXT_DOMAIN) . '</p>',
            '<p>' . __('I want to buy %s ticket(s)', Eab_EventsHub::TEXT_DOMAIN) . '</p>',
            '<input type="number" size="2" name="quantity" value="1" min="1" ' . $extra_attributes . ' />'
          )
        ;
    
        $content .= '<input type="image" name="submit" border="0" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" alt="PayPal - The safer, easier way to pay online" />';
        $content .= '<img alt="" border="0" width="1" height="1" src="https://www.paypal.com/en_US/i/scr/pixel.gif" />';
        $content .= '</form>';
    
      }
    
      return $content;
    }
    add_filter('eab-event-payment_forms', 'my_get_payment_forms' );

    In the couple last lines of $content there are the image links that you want to replace. In order to check for current language of each visitor, you should use the get_locale() function.

    Hope that was some help, let us know, if further assistance is required here.

    Thank you,
    Dimitris

  • Dimitris

    Hello espsjurs

    I'm really sorry for that, let's try another workaround and try to replace only the image source.
    Please replace above snippet with:

    <?php
    add_filter( 'eab-event-payment_forms', function($content){
        return str_replace( 'https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif', 'http://example.com/wp-content/uploads/new-image.jpg', $content );
    } );

    This does the trick in my testing site, without breaking the requests to PayPal.

    Thank you,
    Dimitris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.