update
This commit is contained in:
@@ -33,7 +33,9 @@ function wooProductIsType( $product, $type ) {
|
||||
|
||||
}
|
||||
function wooIsRequestContainOrderId() {
|
||||
global $wp;
|
||||
return isset( $_REQUEST['key'] ) && $_REQUEST['key'] != ""
|
||||
|| !empty($wp->query_vars['order-received'])
|
||||
|| isset( $_REQUEST['referenceCode'] ) && $_REQUEST['referenceCode'] != ""
|
||||
|| isset( $_REQUEST['ref_venta'] ) && $_REQUEST['ref_venta'] != ""
|
||||
|| !empty( $_REQUEST['wcf-order'] );
|
||||
@@ -63,7 +65,28 @@ function getWooProductPriceToDisplay( $product_id, $qty = 1 ) {
|
||||
|
||||
return (float) wc_get_price_to_display( $product, array( 'qty' => $qty,'price'=>$productPrice ) );
|
||||
}
|
||||
/**
|
||||
* @param SingleEvent $event
|
||||
*/
|
||||
function getWooEventCartTotal($event) {
|
||||
|
||||
return getWooEventCartSubtotal($event);
|
||||
}
|
||||
/**
|
||||
* @param SingleEvent $event
|
||||
*/
|
||||
function getWooEventCartSubtotal($event) {
|
||||
$subTotal = 0;
|
||||
$include_tax = get_option( 'woocommerce_tax_display_cart' ) == 'incl';
|
||||
|
||||
foreach ($event->args['products'] as $product) {
|
||||
$subTotal += $product['subtotal'];
|
||||
if($include_tax) {
|
||||
$subTotal += $product['subtotal_tax'];
|
||||
}
|
||||
}
|
||||
return pys_round($subTotal);
|
||||
}
|
||||
function getWooCartSubtotal() {
|
||||
|
||||
// subtotal is always same value on front-end and depends on PYS options
|
||||
@@ -174,6 +197,19 @@ function getWooEventValueOrder( $valueOption, $order, $global, $percent = 100 )
|
||||
|
||||
}
|
||||
|
||||
function get_fees($order){
|
||||
$fees = $order->get_fees();
|
||||
$fee_amount = 0;
|
||||
|
||||
foreach ($fees as $fee) {
|
||||
$fee_amount += $fee->get_total();
|
||||
}
|
||||
if($fee_amount > 0){
|
||||
return $fee_amount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
function getWooEventValueCart( $valueOption, $global, $percent = 100 ) {
|
||||
|
||||
if($valueOption == 'cog' && isPixelCogActive()) {
|
||||
@@ -211,9 +247,33 @@ function getWooEventValueCart( $valueOption, $global, $percent = 100 ) {
|
||||
}
|
||||
|
||||
function wooGetOrderIdFromRequest() {
|
||||
global $wp;
|
||||
if(isset( $_REQUEST['key'] ) && $_REQUEST['key'] != "") {
|
||||
$order_key = sanitize_key($_REQUEST['key']);
|
||||
$order_id = (int) wc_get_order_id_by_order_key( $order_key );
|
||||
$cache_key = 'order_id_' . $order_key;
|
||||
$order_id = get_transient( $cache_key );
|
||||
if (is_order_received_page() && empty($order_id) && $wp->query_vars['order-received']) {
|
||||
|
||||
$order_id = absint( $wp->query_vars['order-received'] );
|
||||
if ($order_id) {
|
||||
set_transient( $cache_key, $order_id, HOUR_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
if ( empty($order_id) ) {
|
||||
$order_id = (int) wc_get_order_id_by_order_key( $order_key );
|
||||
set_transient( $cache_key, $order_id, HOUR_IN_SECONDS );
|
||||
}
|
||||
return $order_id;
|
||||
}
|
||||
if(is_order_received_page() && !empty($wp->query_vars['order-received'])){
|
||||
$cache_key = 'order_id_' . $wp->query_vars['order-received'];
|
||||
$order_id = get_transient( $cache_key );
|
||||
if (empty($order_id)) {
|
||||
$order_id = absint( $wp->query_vars['order-received'] );
|
||||
if ($order_id) {
|
||||
set_transient( $cache_key, $order_id, HOUR_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
return $order_id;
|
||||
}
|
||||
if(isset( $_REQUEST['referenceCode'] ) && $_REQUEST['referenceCode'] != "") {
|
||||
|
||||
Reference in New Issue
Block a user