Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created November 29, 2017 23:12
Show Gist options
  • Save pbrocks/d14289cb5bdfd4b939fe87d81eba81d0 to your computer and use it in GitHub Desktop.
Save pbrocks/d14289cb5bdfd4b939fe87d81eba81d0 to your computer and use it in GitHub Desktop.
/**
* Replacment for lines https://github.com/strangerstudios/pmpro-vat-tax/blob/master/pmpro-vat-tax.php#L530-L570
*/
function pmprovat_pmpro_payment_option_fields( $payment_option_values, $gateway ) {
global $pmpro_european_union, $pmpro_vat_by_country;
if ( isset( $_REQUEST['pmprovt_seller_country'] ) ) {
$seller_country = sanitize_text_field( $_REQUEST['pmprovt_seller_country'] );
update_option( 'pmprovt_seller_country', 'ES' );
} else {
$seller_country = get_option( 'pmprovt_seller_country' );
}
?>
<tr class="pmpro_settings_divider">
<td colspan="2">
<?php _e( 'EU VAT Seller Country', 'pmprovat' ); ?>
</td>
</tr>
<tr>
<th scope="row" valign="top">
<label for="pmprovt_seller_country"><?php _e( 'Seller Country', 'pmprovat' ); ?>:</label>
</th>
<td>
<?php
$espana = get_option( 'pmprovt_seller_country' );
if ( ! $espana ) {
?>
<select id="pmprovt_seller_country" name="pmprovt_seller_country">
<?php
foreach ( $pmpro_european_union as $abbr => $country ) {
?>
<option value="<?php echo $abbr; ?>"
<?php
if ( $abbr == $seller_country ) {
?>
selected="selected"<?php } ?>><?php echo $country; ?></option>
<?php
}
?>
</select>
<?php
} else {
echo ' Espa&ntilde;a & IVA = ' . $pmpro_vat_by_country['ES'];
}
?>
</td>
</tr>
<?php
}
add_action( 'pmpro_payment_option_fields', 'pmprovat_pmpro_payment_option_fields', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment