本文整理汇总了PHP中WC_Payment_Gateway::payment_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Payment_Gateway::payment_fields方法的具体用法?PHP WC_Payment_Gateway::payment_fields怎么用?PHP WC_Payment_Gateway::payment_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Payment_Gateway
的用法示例。
在下文中一共展示了WC_Payment_Gateway::payment_fields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: payment_fields
/**
* Render the payment fields
*
* @since 4.0.0
* @see WC_Payment_Gateway::payment_fields()
* @see SV_WC_Payment_Gateway_Payment_Form class
*/
public function payment_fields()
{
if ($this->supports_payment_form()) {
$this->get_payment_form_instance()->render();
} else {
parent::payment_fields();
}
}
示例2: sanitize_payment_fields
/**
* Sanitize payment fields
* - some gateways include js in their payment fields
*
* @param WC_Payment_Gateway $gateway
* @return mixed|string
*/
protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
{
$html = '';
if ($gateway->has_fields() || $gateway->get_description()) {
ob_start();
$gateway->payment_fields();
$html = ob_get_contents();
ob_end_clean();
// remove script tags
$html = $this->removeDomNodes($html, '//script');
}
return self::trim_html_string($html);
}
示例3: payment_fields
/**
* Payment fields for Realex.
*
* @see WC_Payment_Gateway::payment_fields()
*/
public function payment_fields()
{
if ($this->threedsecure->is_3dsecure_available() && (!is_checkout_pay_page() || isset($_GET['pay_for_order']))) {
parent::payment_fields();
?>
<style type="text/css">#payment ul.payment_methods li label[for='payment_method_realex'] img:nth-child(n+2) { margin-left:1px; }</style>
<?php
return;
}
// default to new card
$card_ref = 'new';
if ($this->vault_available()) {
// get the credit card tokens for the user
$current_user = wp_get_current_user();
$credit_cards = array();
if ($current_user->ID) {
$credit_cards = get_user_meta($current_user->ID, 'woocommerce_realex_cc', true);
}
// if there are saved cards, and one hasn't been selected, default to the first
if ($credit_cards) {
$card_ref = (object) current($credit_cards);
$card_ref = $card_ref->ref;
}
}
?>
<style type="text/css">#payment ul.payment_methods li label[for='payment_method_realex'] img:nth-child(n+2) { margin-left:1px; }</style>
<fieldset>
<?php
if ($this->description) {
?>
<p><?php
echo esc_html($this->description);
?>
<?php
if ($this->is_test_mode()) {
esc_html_e('TEST MODE ENABLED', 'woocommerce-gateway-realex');
}
?>
</p><?php
}
?>
<?php
if ($this->vault_available() && $credit_cards) {
?>
<div>
<p class="form-row form-row-first" style="width:65%;">
<?php
foreach ($credit_cards as $credit_card) {
$credit_card = (object) $credit_card;
?>
<input type="radio" id="<?php
echo esc_attr($credit_card->ref);
?>
" name="realex_card_ref" style="width:auto;" value="<?php
echo esc_attr($credit_card->ref);
?>
" <?php
checked($credit_card->ref, $card_ref);
?>
/>
<label style="display:inline;" for="<?php
echo esc_attr($credit_card->ref);
?>
">
<?php
/* translators: Placeholders: %1$s - credit card type, %2$s - credit card last 4, %3$s - credit card expiration MM/YY */
printf(esc_html__('%1$s ending in %2$s (%3$s)', 'woocommerce-gateway-realex'), $this->card_type_options[$credit_card->type], $credit_card->last4, $credit_card->expiration_month . '/' . $credit_card->expiration_year);
?>
</label><br />
<?php
}
?>
<input type="radio" id="realex_new" name="realex_card_ref" style="width:auto;" <?php
checked('new', $card_ref);
?>
value="0" /> <label style="display:inline;" for="realex_new"><?php
esc_html_e('Use Another Credit Card', 'woocommerce-gateway-realex');
?>
</label>
</p>
<p class="form-row form-row-last" style="width:30%;"><a class="button" href="<?php
echo esc_url(wc_get_page_permalink('myaccount'));
?>
#saved-cards"><?php
echo esc_html($this->managecards);
?>
</a></p>
<div style="clear:both;"></div>
</div>
<div class="clear"></div>
<?php
}
?>
//.........这里部分代码省略.........
示例4: sanitize_payment_fields
/**
* Sanitize payment fields
* - some gateways include js in their payment fields
* @param WC_Payment_Gateway $gateway
* @return mixed|string
*/
protected function sanitize_payment_fields(WC_Payment_Gateway $gateway)
{
$html = '';
if ($gateway->has_fields() || $gateway->get_description()) {
ob_start();
$gateway->payment_fields();
$html = ob_get_contents();
ob_end_clean();
// remove any javascript
// note: DOMDocument causes more problems than it's worth
// $doc = new DOMDocument();
// $doc->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
// $script_tags = $doc->getElementsByTagName('script');
// $length = $script_tags->length;
// for ($i = 0; $i < $length; $i++) {
// $script_tags->item($i)->parentNode->removeChild($script_tags->item($i));
// }
// echo $doc->saveHTML();
// simple preg_replace
$html = preg_replace('/<script.+?<\\/script>/im', '', $html);
}
return $html;
}
示例5: payment_fields
/**
* Render the payment fields
*
* @since 4.0.0
* @see WC_Payment_Gateway::payment_fields()
* @see SV_WC_Payment_Gateway_Payment_Form class
*/
public function payment_fields()
{
if ($this->supports_payment_form()) {
$form = new SV_WC_Payment_Gateway_Payment_Form($this);
$form->render();
} else {
parent::payment_fields();
}
}