public function process_refund($order_id, $amount = null, $reason = '') { if (!$amount) { return false; } /** @var WC_Aplazame $aplazame */ global $aplazame; $client = $aplazame->get_client(); try { $client->refund($order_id, Aplazame_Filters::decimals($amount)); } catch (Aplazame_Exception $e) { return new WP_Error('aplazame_refund_error', sprintf(__('%s Error: "%s"', 'aplazame'), $this->method_title, $e->get_field_error('amount'))); } $aplazame->add_order_note($order_id, sprintf(__('%s has successfully returned %d %s of the order #%s.', 'aplazame'), $this->method_title, $amount, get_woocommerce_currency(), $order_id)); return true; }
case 'variable': $price_selector = $aplazame->settings['price_variable_product_selector']; break; default: $price_selector = $aplazame->settings['price_product_selector']; } ?> <div data-aplazame-simulator="" data-view="product" <?php if (empty($price_selector)) { ?> data-amount="<?php echo esc_attr(Aplazame_Filters::decimals($product->get_price())); ?> " <?php } else { ?> data-price="<?php echo esc_attr($price_selector); ?> " <?php } ?> <?php if (!empty($aplazame->settings['quantity_selector'])) { ?>
/** * @param array $qs * * @return array */ public static function get_history($qs) { $orders = array(); foreach ($qs as $item => $values) { $order = new WC_Order($qs[$item]->ID); $orderDate = new DateTime($order->order_date); $orders[] = array('id' => (string) $order->id, 'amount' => Aplazame_Filters::decimals($order->get_total()), 'due' => '', 'status' => $order->get_status(), 'type' => Aplazame_Helpers::get_payment_method($order->id), 'order_date' => $orderDate->format(DATE_ISO8601), 'currency' => $order->get_order_currency(), 'billing' => self::get_address($order, 'billing'), 'shipping' => self::get_shipping_info($order)); } return $orders; }
<?php if (!defined('ABSPATH')) { exit; } /** @var WC_Aplazame $aplazame */ global $aplazame; if (!$aplazame->enabled) { return; } ?> <div data-aplazame-simulator="" data-view="cart" data-amount="<?php echo esc_attr(Aplazame_Filters::decimals(WC()->cart->total)); ?> " data-currency="<?php echo esc_attr(get_woocommerce_currency()); ?> "> </div>
} </style> <noscript> <?php printf(__('It is necessary to enable JavaScript, %s does not work without JS.', 'aplazame'), 'Aplazame'); ?> </noscript> <p> Aplaza o fracciona tu compra con <a href="https://aplazame.com" target="_blank">Aplazame</a>.<br> Obtén financiación al instante sólo con tu Nombre y Apellidos, DNI/NIE, Teléfono y tarjeta de débito o crédito.<br> Sin comisiones ocultas ni letra pequeña.<br> </p> <script> aplazame.button({ selector: <?php echo json_encode($aplazame->settings['button']); ?> , amount: <?php echo json_encode(Aplazame_Filters::decimals($woocommerce->cart->total)); ?> , currency: <?php echo json_encode(get_woocommerce_currency()); ?> }); </script>
public function confirm() { $order = new WC_Order($_GET['order_id']); $client = $this->get_client(); try { $body = $client->authorize($order->id); } catch (Aplazame_Exception $e) { $order->update_status('failed', sprintf(__('%s ERROR: Order #%s cannot be confirmed.', 'aplazame'), self::METHOD_TITLE, $order->id)); status_header($e->get_status_code()); return null; } if ($body->amount === Aplazame_Filters::decimals($order->get_total())) { $order->update_status('processing', sprintf(__('Confirmed by %s.', 'aplazame'), $this->apiBaseUri)); status_header(204); } else { status_header(403); } return null; }