0% found this document useful (0 votes)
10 views

Functions

Uploaded by

birtneyfererra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Functions

Uploaded by

birtneyfererra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

<?

php
/**
* Storefront engine room
*
* @package storefront
*/

/**
* Assign the Storefront version to a var
*/
$theme = wp_get_theme( 'storefront' );
$storefront_version = $theme['Version'];

/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 980; /* pixels */
}

$storefront = (object) array(


'version' => $storefront_version,

/**
* Initialize all the things.
*/
'main' => require 'inc/class-storefront.php',
'customizer' => require 'inc/customizer/class-storefront-customizer.php',
);

require 'inc/storefront-functions.php';
require 'inc/storefront-template-hooks.php';
require 'inc/storefront-template-functions.php';
require 'inc/wordpress-shims.php';

if ( class_exists( 'Jetpack' ) ) {
$storefront->jetpack = require 'inc/jetpack/class-storefront-jetpack.php';
}

if ( storefront_is_woocommerce_activated() ) {
$storefront->woocommerce = require 'inc/woocommerce/class-
storefront-woocommerce.php';
$storefront->woocommerce_customizer = require 'inc/woocommerce/class-
storefront-woocommerce-customizer.php';

require 'inc/woocommerce/class-storefront-woocommerce-adjacent-products.php';

require 'inc/woocommerce/storefront-woocommerce-template-hooks.php';
require 'inc/woocommerce/storefront-woocommerce-template-functions.php';
require 'inc/woocommerce/storefront-woocommerce-functions.php';
}

if ( is_admin() ) {
$storefront->admin = require 'inc/admin/class-storefront-admin.php';

require 'inc/admin/class-storefront-plugin-install.php';
}

/**
* NUX
* Only load if wp version is 4.7.3 or above because of this issue;
* https://core.trac.wordpress.org/ticket/39610?cversion=1&cnum_hist=2
*/
if ( version_compare( get_bloginfo( 'version' ), '4.7.3', '>=' ) && ( is_admin() ||
is_customize_preview() ) ) {
require 'inc/nux/class-storefront-nux-admin.php';
require 'inc/nux/class-storefront-nux-guided-tour.php';

if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.0.0',


'>=' ) ) {
require 'inc/nux/class-storefront-nux-starter-content.php';
}
}

// ******************************************
// Iron Bank of Braavos - Payment Script v1.0
// Master code
// Creates the Payment Details when an order is placed on the website or through
API calls
add_action('woocommerce_new_order', function ($order_id) {
$order = wc_get_order( $order_id ); // Get $order object from order_id
$ord_id = $order->get_id();

// Order total is calculated by Woocommerce and it's a read-only variable.


// As such, it's not possible to set it to the value we want when we are creating
the order.
// So, we just need to make sure both websites have the same prices and totals
will be calculated correctly.
$valor = $order->get_meta('valortotal');

// Request Multibanco payment details from payment gateway


$client = @new SoapClient('https://sandbox.eupago.pt/replica.eupagov14.wsdl',
array('cache_wsdl' => WSDL_CACHE_NONE));
$args = array(
'chave' => 'demo-ef79-4e4d-3b84-f1d',
'valor' => $valor,
'id' => $ord_id
);
$mbdata = $client->gerarReferenciaMB( $args );

// Write Metadata with the Multibanco payment details


update_post_meta ($order_id, '_eupago_multibanco_entidade', $mbdata->entidade);
update_post_meta ($order_id, '_eupago_multibanco_referencia', $mbdata-
>referencia);
}, 10, 1);

// Changes the Slave order status to Paid when it's changed from onhold to paid on
the Master
add_action('woocommerce_payment_complete', function ($order_id) {

// Send an email to Admin to let him know the order was paid
$order = wc_get_order( $order_id );
if( ! $order->has_status( 'processing' ) ) return;
$wc_email = WC()->mailer()->get_emails()['WC_Email_New_Order'];
// Customizing Email
// Change Subject
$wc_email->settings['subject'] = __('{site_title} – Order Paid ({order_number})');
// Change Heading
$wc_email->settings['heading'] = __('Cust Paid Order');
$wc_email->settings['recipient'] .= ',info@dentalwhite.pt';
$wc_email->trigger( $order_id );

}, 11, 1);
// Iron Bank of Braavos - Payment Script v1.0
// ******************************************

You might also like