WordPress.org

Ready to get started?Download WordPress

Forums

PayPal Express Checkout
BuyNow button If terms and conditions checked (3 posts)

  1. riwa
    Member
    Posted 1 year ago #

    Hello,

    I used the BuyNow short codes in my checkout page.

    I would like it to appear/be active only if the terms and conditions box is checked, is that possible ?

    Thank you.

    http://wordpress.org/extend/plugins/paypal-express-checkout/

  2. ykhaled
    Member
    Posted 1 year ago #

    Have a look at plugins/paypal-express-checkout/views/frontendcode.php
    You can add a checkbox there plus a small javascript that check if ticked when submit is enabled.
    Code is currently as follows:

    <form method="post" action="<?php echo $config->getItem('plugin_form_handler_url'); ?>">
      <input type="hidden" name="AMT" value="<?php echo $atts['amount']; ?>" />
      <input type="hidden" name="CURRENCYCODE" value="<?php echo $atts['currency']; ?>" />
      <?php if ( isset($atts['description']) ) { ?>
        <input type="hidden" name="PAYMENTREQUEST_0_DESC" value="<?php echo $atts['description']; ?>" />
      <?php } ?>
    
      <?php if ( isset($atts['tax']) ) { ?>
        <input type="hidden" name="TAXAMT" value="<?php echo $atts['tax']; ?>" />
      <?php } ?>
    
      <?php if ( isset($atts['shipping']) ) { ?>
        <input type="hidden" name="SHIPPINGAMT" value="<?php echo $atts['shipping']; ?>" />
      <?php } ?>
    
      <?php if ( isset($atts['handling']) ) { ?>
        <input type="hidden" name="HANDLINGAMT" value="<?php echo $atts['handling']; ?>" />
      <?php } ?>
    
      <?php if ( isset($atts['qty']) ) { ?>
        <input type="hidden" name="PAYMENTREQUEST_0_QTY" value="<?php echo $atts['qty']; ?>" />
      <?php } ?>
    
      <?php if ( isset($atts['return_url']) ) { ?>
        <input type="hidden" name="RETURN_URL" value="<?php echo $atts['return_url']; ?>" />
      <?php } ?>
    
      <?php if ( isset($atts['cancel_url']) ) { ?>
        <input type="hidden" name="CANCEL_URL" value="<?php echo $atts['cancel_url']; ?>" />
      <?php } ?>
    
      <input type="hidden" name="func" value="start" />
    
      <?php if ( isset($atts['button_style']) ) { ?>
        <?php if ( $atts['button_style'] == 'buy_now' ) { ?>
          <input type="image" value="" src="<?php echo $config->getItem('buy_now_button_src'); ?>" />
        <?php } elseif ( $atts['button_style'] == 'checkout' ) { ?>
          <input type="image" value="" src="<?php echo $config->getItem('checkout_button_src'); ?>" />
        <?php } ?>
      <?php } else { ?>
        <input type="submit" value="Pay with PayPal" />
      <?php } ?>
    </form>

    Add somewhere :

    <input type="checkbox" name="terms" value="agree">Agree terms and conditions<br>

    And add onsubmit="return checkifagree()" also give it a name so the form header looks like this:

    <form name="paypal_form" method="post" action="<?php echo $config->getItem('plugin_form_handler_url'); ?> " onsubmit="return checkifagree()">

    finally define checkifagree() function and do the checks.

    function validateimeiWidget()
    {
    var checkbox=document.forms["paypal_form"]["terms"].value;
       if( checkbox == ''agree")
           {
               return true;
          }
    return false;
    
    }

    I am not a programmer; please test and bespoke the code as you wish; this is just to give you an idea. If you managed to get it to work please share your code :)

  3. ykhaled
    Member
    Posted 1 year ago #

    sorry I pasted the wrong function name:
    function validateimeiWidget()
    should be
    function checkifagree()

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.