Ejemplo n.º 1
0
        /**
         * Create a print button for the 'View Order' page
         */
        public function create_print_button_order_page($order_id)
        {
            $order = new WC_Order($order_id);
            // Output the button only when the option is enabled
            if (get_option(WooCommerce_Delivery_Notes::$plugin_prefix . 'print_button_on_view_order_page')) {
                // Default button for all pages and logged in users
                $print_url = wcdn_get_print_link($order_id, $this->get_template_type($order));
                // Pass the email to the url for the tracking
                // and thank you page. This allows to view the
                // print page without logging in.
                if ($this->is_woocommerce_tracking_page()) {
                    $print_url = wcdn_get_print_link($order_id, $this->get_template_type($order), $_REQUEST['order_email']);
                }
                // Thank you page
                if (is_order_received_page() && !is_user_logged_in()) {
                    // Don't output the butten when there is no email
                    if (!$order->billing_email) {
                        return;
                    }
                    $print_url = wcdn_get_print_link($order_id, $this->get_template_type($order), $order->billing_email);
                }
                ?>
				<p class="order-print">
					<a href="<?php 
                echo $print_url;
                ?>
" class="button print"><?php 
                _e('Print', 'woocommerce-delivery-notes');
                ?>
</a>
				</p>
				<?php 
            }
        }
function ctala_theme_name_scripts()
{
    if (is_order_received_page() || is_checkout()) {
        $dir = plugin_dir_url(__FILE__);
        $bootstrapMin = $dir . "css/bootstrap.min.css";
        wp_enqueue_style('ctala_bootstrap', $bootstrapMin);
    }
}
function tapfiliate()
{
    global $post;
    $postName = $post ? $post->post_name : null;
    $tap_account_id = get_option('tap_account_id');
    $integrate_for = get_option('integrate_for');
    $thank_you_page = get_option('thank_you_page');
    $query_parameter_transaction_id = get_option('query_parameter_transaction_id');
    $query_parameter_transaction_amount = get_option('query_parameter_transaction_amount');
    ?>
<script src="//tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  window['TapfiliateObject'] = i = 'tap';
  window[i] = window[i] || function () {
      (window[i].q = window[i].q || []).push(arguments);
  };

  tap('create', '<?php 
    echo $tap_account_id;
    ?>
');
  <?php 
    if ($integrate_for == 'wp') {
        if ($postName == $thank_you_page) {
            $cid = isset($_GET[$query_parameter_transaction_id]) && !empty($_GET[$query_parameter_transaction_id]) ? "'{$_GET[$query_parameter_transaction_id]}'" : 'null';
            $cam = isset($_GET[$query_parameter_transaction_amount]) && !empty($_GET[$query_parameter_transaction_amount]) ? $_GET[$query_parameter_transaction_amount] : 'null';
            echo "tap('conversion', {$cid}, {$cam});";
        } else {
            echo "tap('detectClick');";
        }
    } elseif ($integrate_for == 'wc') {
        if (function_exists("is_order_received_page") && is_order_received_page()) {
            if (isset($GLOBALS['order-received'])) {
                $order_id = apply_filters('woocommerce_thankyou_order_id', absint($GLOBALS['order-received']));
                $order_key = apply_filters('woocommerce_thankyou_order_key', empty($_GET['key']) ? '' : wc_clean($_GET['key']));
                if ($order_id > 0) {
                    $order = new WC_Order($order_id);
                    if ($order->order_key != $order_key) {
                        unset($order);
                    }
                }
                echo "tap('conversion', '{$order->id}', {$order->get_total()});";
            }
        } else {
            echo "tap('detectClick');";
        }
    }
    ?>
</script>
<?php 
}
 /**
  * Display tracking code globally and on the order received page
  *
  * @return string
  */
 public function display_tracking_code()
 {
     global $wp;
     if (is_admin() || current_user_can('manage_options')) {
         return;
     }
     $this->output_global_tracking_code();
     if (is_order_received_page()) {
         $order_id = isset($wp->query_vars['order-received']) ? $wp->query_vars['order-received'] : 0;
         if (0 < $order_id) {
             $this->output_order_tracking_code($order_id);
         }
     }
 }
 /**
  * Display the tracking codes
  *
  * @return string
  */
 public function tracking_code_display()
 {
     global $wp;
     $display_ecommerce_tracking = false;
     if (is_admin() || current_user_can('manage_options') || !$this->ga_id) {
         return;
     }
     // Check if is order received page and stop when the products and not tracked
     if (is_order_received_page() && 'yes' == $this->ga_ecommerce_tracking_enabled) {
         $order_id = isset($wp->query_vars['order-received']) ? $wp->query_vars['order-received'] : 0;
         if (0 < $order_id && 1 != get_post_meta($order_id, '_ga_tracked', true)) {
             $display_ecommerce_tracking = true;
             echo $this->get_ecommerce_tracking_code($order_id);
         }
     }
     if (!$display_ecommerce_tracking && 'yes' == $this->ga_standard_tracking_enabled) {
         echo $this->get_google_tracking_code();
     }
 }
Ejemplo n.º 6
0
/**
 * Override template on WooCommerce Page
 */
function colabs_wc_template_loader($template)
{
    global $post;
    if (colabs_check_plugin_active('woocommerce/woocommerce.php')) {
        $myaccount_page_id = wc_get_page_id('myaccount');
        // My Account Page
        if ($post->ID == $myaccount_page_id) {
            $template = locate_template(array('woocommerce/page-myaccount.php'));
        } else {
            if (is_cart()) {
                $template = locate_template(array('woocommerce/page-cart.php'));
            } else {
                if (is_checkout()) {
                    $template = locate_template(array('woocommerce/page-checkout.php'));
                } else {
                    if (is_order_received_page()) {
                        $template = locate_template(array('woocommerce/page-thanks.php'));
                    }
                }
            }
        }
    }
    return $template;
}
Ejemplo n.º 7
0
 function woo_layout_body_class($classes)
 {
     global $post, $wp_query, $woo_options;
     $layout = '';
     // Single post layout
     if (is_singular()) {
         // Get layout setting from single post Custom Settings panel
         $layout = get_post_meta($post->ID, 'layout', true);
         // Set to single post layout if selected
         if ($layout != '') {
             $woo_options['woo_layout'] = $layout;
             // Portfolio single post layout option.
         } elseif (get_post_type() == 'portfolio') {
             $portfolio_single_layout = get_option('woo_portfolio_layout_single');
             if ($portfolio_single_layout != '') {
                 $layout = $portfolio_single_layout;
                 $woo_options['woo_layout'] = $portfolio_single_layout;
             }
         }
     }
     // Set default global layout
     if ($layout == '') {
         $layout = get_option('woo_layout');
         if ($layout == '') {
             $layout = 'two-col-left';
         }
     }
     // Portfolio gallery layout option.
     if (is_tax('portfolio-gallery') || is_post_type_archive('portfolio') || is_page_template('template-portfolio.php')) {
         $portfolio_gallery_layout = get_option('woo_portfolio_layout');
         if ($portfolio_gallery_layout != '') {
             $layout = $portfolio_gallery_layout;
         }
     }
     if (is_tax('portfolio-gallery') || is_post_type_archive('portfolio') || is_page_template('template-portfolio.php') || is_singular() && get_post_type() == 'portfolio') {
         $classes[] = 'portfolio-component';
     }
     // WooCommerce Layout
     if (class_exists('woocommerce') && function_exists('is_shop') && function_exists('is_cart') && function_exists('is_checkout') && function_exists('is_account_page') && function_exists('is_product') && function_exists('is_order_received_page') && (is_woocommerce() || is_shop() || is_cart() || is_checkout() || is_account_page() || is_product() || is_order_received_page())) {
         // Set defaul layout
         $woocommerce_layout = get_option('woo_wc_layout');
         if ($woocommerce_layout != '') {
             $layout = $woocommerce_layout;
             $woo_options['woo_layout'] = $woocommerce_layout;
         }
         // WooCommerce single post/page
         if (is_singular()) {
             // Get layout setting from single post Custom Settings panel
             $single_layout = get_post_meta($post->ID, 'layout', true);
             // Set to single post layout if selected
             if ($single_layout != '') {
                 $woo_options['woo_layout'] = $single_layout;
                 $layout = $single_layout;
             }
         }
     }
     // Specify site width
     $width = intval(str_replace('px', '', get_option('woo_layout_width', '960')));
     // Add classes to body_class() output
     $classes[] = $layout;
     $classes[] = 'width-' . $width;
     $classes[] = $layout . '-' . $width;
     return $classes;
 }
Ejemplo n.º 8
0
 /**
  * @param WC_Order $order
  */
 public static function onOrderDetails(WC_Order $order)
 {
     if (is_order_received_page()) {
         /**
          * Do not show instruction again below details on order received page
          * Instructions already displayed on top of order received page by $gateway->thankyou_page()
          *
          * @see Mollie_WC_Gateway_Abstract::thankyou_page
          */
         return;
     }
     $gateway = Mollie_WC_Plugin::getDataHelper()->getWcPaymentGatewayByOrder($order);
     if (!$gateway || !$gateway instanceof Mollie_WC_Gateway_Abstract) {
         return;
     }
     /** @var Mollie_WC_Gateway_Abstract $gateway */
     $gateway->displayInstructions($order);
 }
Ejemplo n.º 9
0
function gtm4wp_woocommerce_datalayer_filter_items($dataLayer)
{
    global $woocommerce, $gtm4wp_options, $wp_query, $gtm4wp_datalayer_name, $gtm4wp_product_counter;
    if (is_product_category() || is_product_tag() || is_front_page() || is_shop()) {
        if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING] || true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
            if (count($woocommerce->query->filtered_product_ids) > 0) {
                // The following 5 lines are being borrowed from WC source
                $paged = max(1, $wp_query->get('paged'));
                $per_page = $wp_query->get('posts_per_page');
                $total = $wp_query->found_posts;
                $first = $per_page * $paged - $per_page + 1;
                $last = min($total, $wp_query->get('posts_per_page') * $paged);
                $gtm4wp_product_counter = $first;
                $sumprice = 0;
                $product_ids = array();
                $product_impressions = array();
                $_temp_product_id_list = $woocommerce->query->filtered_product_ids;
                $i = $first - 1;
                foreach ($_temp_product_id_list as $itemid => $oneproductid) {
                    $product = get_product($oneproductid);
                    if (false === $product) {
                        continue;
                    }
                    $product_price = $product->get_price();
                    $_product_cats = get_the_terms($product->id, 'product_cat');
                    if (is_array($_product_cats) && count($_product_cats) > 0) {
                        $product_cat = array_pop($_product_cats);
                        $product_cat = $product_cat->name;
                    } else {
                        $product_cat = "";
                    }
                    $sumprice += $product_price;
                    $product_ids[] = "'" . $oneproductid . "'";
                    $product_impressions[] = "{'name': '" . str_replace("'", "\\'", $product->get_title()) . "', 'id': '" . $oneproductid . "', 'price': '" . $product_price . "', 'category': '" . str_replace("'", "\\'", $product_cat) . "', 'position': " . ($i + 1) . " }";
                    $i++;
                    if ($i > $last) {
                        break;
                    }
                }
                if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING]) {
                    $dataLayer["ecomm_prodid"] = '-~-[' . implode(", ", $product_ids) . ']-~-';
                    $dataLayer["ecomm_pagetype"] = is_front_page() ? "home" : "category";
                    $dataLayer["ecomm_totalvalue"] = $sumprice;
                }
                if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                    $dataLayer["ecommerce"] = "-~-{'impressions': [" . implode(", ", $product_impressions) . "]}-~-";
                }
            }
        }
    } else {
        if (is_product()) {
            if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING] || true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                $prodid = get_the_ID();
                $product = get_product($prodid);
                $product_price = $product->get_price();
                $_product_cats = get_the_terms($product->id, 'product_cat');
                if (is_array($_product_cats) && count($_product_cats) > 0) {
                    $product_cat = array_pop($_product_cats);
                    $product_cat = $product_cat->name;
                } else {
                    $product_cat = "";
                }
                if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING]) {
                    $dataLayer["ecomm_prodid"] = $prodid;
                    $dataLayer["ecomm_pagetype"] = "product";
                    $dataLayer["ecomm_totalvalue"] = $product_price;
                }
                if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                    $dataLayer["ecommerce"] = "-~-{'detail': {'products': [{'name': '" . str_replace("'", "", get_the_title()) . "', 'id': '" . $prodid . "', 'price': '" . $product_price . "', 'category': '" . str_replace("'", "", $product_cat) . "'}]}}-~-";
                }
            }
        } else {
            if (is_cart()) {
                if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                    gtm4wp_woocommerce_addjs("\r\n\t\t\$('.product-remove').click(function() {\r\n\t\t\tvar productdata = \$( this )\r\n\t\t\t\t.parent()\r\n\t\t\t\t.find( '.gtm4wp_productdata' );\r\n\t\t\t\r\n\t\t\t" . $gtm4wp_datalayer_name . ".push({\r\n\t\t\t\t'event': 'gtm4wp.removeFromCart',\r\n\t\t\t\t'ecommerce': {\r\n\t\t\t\t\t'remove': {\r\n\t\t\t\t\t\t'products': [{\r\n\t\t\t\t\t\t\t'name':     productdata.data( 'product_name' ),\r\n\t\t\t\t\t\t\t'id':       productdata.data( 'product_id' ),\r\n\t\t\t\t\t\t\t'price':    productdata.data( 'product_price' ),\r\n\t\t\t\t\t\t\t'category': productdata.data( 'product_cat' ),\r\n\t\t\t\t\t\t\t'quantity': \$( this ).parent().parent().find( '.product-quantity input.qty' ).val()\r\n\t\t\t\t\t\t}]\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\t\t\t");
                }
                if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING]) {
                    $products = $woocommerce->cart->get_cart();
                    $product_ids = array();
                    foreach ($products as $oneproduct) {
                        $product_ids[] = "'" . str_replace("'", "\\'", $oneproduct['product_id']) . "'";
                    }
                    $dataLayer["ecomm_prodid"] = '-~-[' . implode(", ", $product_ids) . ']-~-';
                    $dataLayer["ecomm_pagetype"] = "cart";
                    $dataLayer["ecomm_totalvalue"] = $woocommerce->cart->cart_contents_total;
                }
            } else {
                if (is_order_received_page()) {
                    $order_id = apply_filters('woocommerce_thankyou_order_id', empty($_GET['order']) ? $GLOBALS["wp"]->query_vars["order-received"] ? $GLOBALS["wp"]->query_vars["order-received"] : 0 : absint($_GET['order']));
                    $order_key = apply_filters('woocommerce_thankyou_order_key', empty($_GET['key']) ? '' : woocommerce_clean($_GET['key']));
                    if ($order_id > 0) {
                        $order = new WC_Order($order_id);
                        if ($order->order_key != $order_key) {
                            unset($order);
                        }
                    }
                    if (1 == get_post_meta($order_id, '_ga_tracked', true)) {
                        unset($order);
                    }
                    if (isset($order)) {
                        if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC]) {
                            $dataLayer["transactionId"] = $order->get_order_number();
                            $dataLayer["transactionDate"] = date("c");
                            $dataLayer["transactionType"] = "sale";
                            $dataLayer["transactionAffiliation"] = get_bloginfo('name');
                            $dataLayer["transactionTotal"] = $order->get_total();
                            $dataLayer["transactionShipping"] = $order->get_total_shipping();
                            $dataLayer["transactionTax"] = $order->get_total_tax();
                            $dataLayer["transactionPaymentType"] = $order->payment_method_title;
                            $dataLayer["transactionCurrency"] = get_woocommerce_currency();
                            $dataLayer["transactionShippingMethod"] = $order->get_shipping_method();
                            $dataLayer["transactionPromoCode"] = implode(", ", $order->get_used_coupons());
                        }
                        if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                            $dataLayer["ecommerce"] = "-~-{'purchase': {'actionField': {'id': '" . $order->get_order_number() . "', 'affiliation': '" . get_bloginfo('name') . "', 'revenue': '" . $order->get_total() . "', 'tax': '" . $order->get_total_tax() . "', 'shipping': '" . $order->get_total_shipping() . "'}, ";
                        }
                        $_products = array();
                        $_sumprice = 0;
                        $_product_ids = array();
                        if ($order->get_items()) {
                            foreach ($order->get_items() as $item) {
                                $_product = $order->get_product_from_item($item);
                                $variation_data = null;
                                if (get_class($_product) == "WC_Product_Variation") {
                                    $variation_data = $_product->get_variation_attributes();
                                }
                                if (isset($variation_data)) {
                                    $_category = woocommerce_get_formatted_variation($_product->variation_data, true);
                                } else {
                                    $out = array();
                                    $categories = get_the_terms($_product->id, 'product_cat');
                                    if ($categories) {
                                        foreach ($categories as $category) {
                                            $out[] = $category->name;
                                        }
                                    }
                                    $_category = implode(" / ", $out);
                                }
                                $_prodprice = $order->get_item_total($item);
                                $_products[] = array("id" => $_product->id, "name" => $item['name'], "sku" => $_product->get_sku() ? __('SKU:', GTM4WP_TEXTDOMAIN) . ' ' . $_product->get_sku() : $_product->id, "category" => $_category, "price" => $_prodprice, "currency" => get_woocommerce_currency(), "quantity" => $item['qty']);
                                $_sumprice += $_prodprice;
                                $_product_ids[] = "'" . $_product->id . "'";
                            }
                        }
                        if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC]) {
                            $dataLayer["transactionProducts"] = $_products;
                            $dataLayer["event"] = "gtm4wp.orderCompleted";
                        }
                        if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                            $dataLayer["ecommerce"] .= "'products': " . str_replace('"', "'", json_encode($_products)) . " }}-~-";
                            $dataLayer["event"] = "gtm4wp.orderCompleted";
                        }
                        if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING]) {
                            $dataLayer["ecomm_prodid"] = '-~-[' . implode(", ", $_product_ids) . ']-~-';
                            $dataLayer["ecomm_pagetype"] = "purchase";
                            $dataLayer["ecomm_totalvalue"] = $_sumprice;
                        }
                        //			update_post_meta( $order_id, '_ga_tracked', 1 );
                    }
                } else {
                    if (is_checkout()) {
                        if (true === $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC]) {
                            foreach ($woocommerce->cart->get_cart() as $cart_item_id => $cart_item_data) {
                                $product = $cart_item_data["data"];
                                $_product_cats = get_the_terms($product->id, 'product_cat');
                                if (is_array($_product_cats) && count($_product_cats) > 0) {
                                    $product_cat = array_pop($_product_cats);
                                    $product_cat = $product_cat->name;
                                } else {
                                    $product_cat = "";
                                }
                                $gtm4wp_checkout_products[] = "{'name': '" . str_replace("'", "\\'", $product->post->post_title) . "', 'id': '" . $product->id . "', 'price': '" . $product->get_price() . "', 'category': '" . $product_cat . "', 'quantity': '" . $cart_item_data["quantity"] . "'}";
                            }
                            $dataLayer["ecommerce"] = "-~-{'checkout': {'actionField': {'step': 1}, 'products':[" . implode(", ", $gtm4wp_checkout_products) . "]}}-~-";
                        }
                    } else {
                        if ($gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCREMARKETING]) {
                            $dataLayer["ecomm_pagetype"] = "siteview";
                        }
                    }
                }
            }
        }
    }
    return $dataLayer;
}
 /**
  * Handles the subscription upgrade/downgrade process.
  *
  * @since 1.4
  */
 public static function subscription_switch_handler()
 {
     global $woocommerce, $post;
     // If the current user doesn't own the subscription, remove the query arg from the URL
     if (isset($_GET['switch-subscription'])) {
         // Visiting a switch link for someone elses subscription
         if (!WC_Subscriptions_Manager::user_owns_subscription($_GET['switch-subscription'])) {
             wp_redirect(remove_query_arg('switch-subscription'));
             exit;
         } else {
             if (isset($_GET['auto-switch'])) {
                 $switch_message = __('You have an active subscription to this product. Choosing a new subscription will replace your existing subscription.', 'woocommerce-subscriptions');
             } else {
                 $switch_message = __('Choose a new subscription.', 'woocommerce-subscriptions');
             }
             WC_Subscriptions::add_notice($switch_message, 'notice');
         }
     } elseif ((is_cart() || is_checkout()) && !is_order_received_page() && false !== ($cart_item = self::cart_contains_subscription_switch())) {
         if (!WC_Subscriptions_Manager::user_owns_subscription($cart_item['subscription_key'])) {
             WC_Subscriptions::add_notice(__('Your cart contained an invalid subscription switch request and has been emptied.', 'woocommerce-subscriptions'), 'error');
             $woocommerce->cart->empty_cart(true);
             wp_redirect($woocommerce->cart->get_cart_url());
             exit;
         } else {
             WC_Subscriptions::add_notice(__('Once sign up is complete, this will replace your existing subscription.', 'woocommerce-subscriptions'), 'notice');
         }
     } elseif (is_product() && ($product = get_product($post))) {
         // Automatically initiate the switch process for limited variable subscriptions
         if (($product->is_type(array('variable-subscription', 'subscription_variation')) || 0 !== $product->post->post_parent) && WC_Subscriptions_Product::is_subscription($product->id) && 'no' != $product->limit_subscriptions) {
             // is switching enabled for variable or variable_grouped
             $allow_switching = in_array(get_option(WC_Subscriptions_Admin::$option_prefix . '_allow_switching', 'no'), array('variable', 'variable_grouped')) ? true : false;
             if ($allow_switching) {
                 // Check if the user has an active subscription for this product, and if so, initiate the switch process
                 $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions();
                 foreach ($subscriptions as $subscription_key => $subscription) {
                     if ($subscription['product_id'] == $product->id && 'active' == $subscription['status']) {
                         wp_redirect(add_query_arg('auto-switch', 'true', self::get_switch_link($subscription_key)));
                         exit;
                     }
                 }
             } else {
                 WC_Subscriptions::add_notice(__('You have already subscribed to this product and it is limited to one per customer. You can not purchase the product again.', 'woocommerce-subscriptions'), 'notice');
             }
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Add course link to order thank you and details pages.
  *
  * @since  1.4.5
  * @access public
  *
  * @return void
  */
 public static function course_link_from_order()
 {
     if (!is_order_received_page()) {
         return;
     }
     $order_id = get_query_var('order-received');
     $order = new WC_Order($order_id);
     // exit early if not wc-completed or wc-processing
     if ('wc-completed' != $order->post_status && 'wc-processing' != $order->post_status) {
         return;
     }
     $course_links = array();
     // store the for links for courses purchased
     foreach ($order->get_items() as $item) {
         if (isset($item['variation_id']) && 0 < $item['variation_id']) {
             // If item has variation_id then its a variation of the product
             $item_id = $item['variation_id'];
         } else {
             //If not its real product set its id to item_id
             $item_id = $item['product_id'];
         }
         // End If Statement
         $user_id = get_post_meta($order->id, '_customer_user', true);
         if ($user_id) {
             // Get all courses for product
             $args = Sensei_Course::get_default_query_args();
             $args['meta_query'] = array(array('key' => '_course_woocommerce_product', 'value' => $item_id));
             $args['orderby'] = 'menu_order date';
             $args['order'] = 'ASC';
             // loop through courses
             $courses = get_posts($args);
             if ($courses && count($courses) > 0) {
                 foreach ($courses as $course) {
                     $title = $course->post_title;
                     $permalink = get_permalink($course->ID);
                     $course_links[] .= '<a href="' . esc_url($permalink) . '" >' . $title . '</a> ';
                 }
                 // end for each
                 // close the message div
             }
             // end if $courses check
         }
     }
     // end loop through orders
     // add the courses to the WooCommerce notice
     if (!empty($course_links)) {
         $courses_html = _nx('You have purchased the following course:', 'You have purchased the following courses:', count($course_links), 'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei');
         foreach ($course_links as $link) {
             $courses_html .= '<li>' . $link . '</li>';
         }
         $courses_html .= ' </ul>';
         wc_add_notice($courses_html, 'success');
     }
 }
    /**
     * Enhanced Ecommerce GA plugin Settings 
     *
     * @access public
     * @return void
     */
    function ee_settings()
    {
        global $woocommerce;
        //common validation----start
        if (is_admin() || current_user_can("manage_options") || $this->ga_ST == "no") {
            return;
        }
        $tracking_id = $this->ga_id;
        if (!$tracking_id) {
            return;
        }
        //common validation----end
        if (!empty($this->ga_Dname)) {
            $set_domain_name = esc_js($this->ga_Dname);
        } else {
            $set_domain_name = "auto";
        }
        //add display features
        if ($this->ga_DF) {
            $ga_display_feature_code = 'ga("require", "displayfeatures");';
        } else {
            $ga_display_feature_code = "";
        }
        $code = '        
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,"script","//www.google-analytics.com/analytics.js","ga");
                        ga("create", "' . esc_js($tracking_id) . '", "' . $set_domain_name . '");
                        ' . $ga_display_feature_code . '
                      
                        ga("send", "pageview");';
        //include this on all pages except order confirmation page.
        if (!is_order_received_page()) {
            echo "<script>" . $code . "</script>";
        }
    }
    /**
     * Print the tracking pixel to wp_head
     */
    public function fb_tracking_pixel()
    {
        // only show the pixel if a tracking ID is defined
        if (!$this->fbid) {
            return;
        }
        ?>
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');

fbq('init', '<?php 
        echo esc_html($this->fbid);
        ?>
');
fbq('track', 'PageView');

<?php 
        if (is_singular('product') && $this->event_viewcontent) {
            global $post;
            $product = wc_get_product($post->ID);
            $params = array();
            $params['content_name'] = $product->get_title();
            $params['content_ids'] = array($product->get_sku() ? $product->get_sku() : $product->id);
            $params['content_type'] = 'product';
            $params['value'] = floatval($product->get_price());
            $params['currency'] = get_woocommerce_currency();
            ?>
fbq('track', 'ViewContent', <?php 
            echo json_encode($params);
            ?>
);
<?php 
        }
        ?>

<?php 
        if (is_order_received_page() && $this->event_purchase) {
            global $wp;
            $params = array();
            $order_id = isset($wp->query_vars['order-received']) ? $wp->query_vars['order-received'] : 0;
            if ($order_id) {
                $params['order_id'] = $order_id;
                $order = new WC_Order($order_id);
                if ($order->get_items()) {
                    $productids = array();
                    foreach ($order->get_items() as $item) {
                        $product = $order->get_product_from_item($item);
                        $productids[] = $product->get_sku() ? $product->get_sku() : $product->id;
                    }
                    $params['content_ids'] = $productids;
                }
                $params['content_type'] = 'product';
                $params['value'] = $order->get_total();
                $params['currency'] = get_woocommerce_currency();
            }
            ?>
fbq('track', 'Purchase', <?php 
            echo json_encode($params);
            ?>
);

<?php 
        } elseif (is_checkout() && $this->event_checkout) {
            // get $cart to params
            $cart = WC()->cart->get_cart();
            $productids = array();
            foreach ($cart as $id => $item) {
                $product_id = $item['variation_id'] ? $item['variation_id'] : $item['product_id'];
                $product = new WC_Product($product_id);
                $productids[] = $product->get_sku() ? $product->get_sku() : $product->id;
            }
            $params = array();
            $params['num_items'] = WC()->cart->cart_contents_count;
            $params['value'] = WC()->cart->total;
            $params['currency'] = get_woocommerce_currency();
            $params['content_ids'] = $productids;
            ?>
fbq('track', 'InitiateCheckout', <?php 
            echo json_encode($params);
            ?>
);
<?php 
        }
        ?>


</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=<?php 
        echo esc_html($this->fbid);
        ?>
&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
<?php 
    }
Ejemplo n.º 14
0
 function is_woocommerce_page()
 {
     return is_cart() || is_checkout() || is_account_page() || is_order_received_page() || is_product_category() || is_product_tag() || is_product() ? true : false;
 }
Ejemplo n.º 15
0
function dh_get_post_meta($meta = '', $post_id = '', $default = null)
{
    $post_id = empty($post_id) ? get_the_ID() : $post_id;
    if (defined('WOOCOMMERCE_VERSION')) {
        if (is_shop()) {
            $post_id = wc_get_page_id('shop');
        } elseif (is_cart()) {
            $post_id = wc_get_page_id('cart');
        } elseif (is_checkout()) {
            $post_id = wc_get_page_id('checkout');
        } elseif (is_account_page()) {
            $post_id = wc_get_page_id('myaccount');
        } elseif (is_order_received_page()) {
            $post_id = wc_get_page_id('checkout');
        } elseif (is_add_payment_method_page()) {
            $post_id = wc_get_page_id('myaccount');
        }
    }
    if (is_search()) {
        $post_id = 0;
    }
    if (empty($meta)) {
        return false;
    }
    $value = get_post_meta($post_id, '_dh_' . $meta, true);
    if ($value !== '' && $value !== null && $value !== array() && $value !== false) {
        return apply_filters('dh_get_post_meta', $value, $meta, $post_id);
    }
    return $default;
}
 function tbz_wc_voguepay_message()
 {
     if (get_query_var('order-received')) {
         $order_id = absint(get_query_var('order-received'));
         $order = wc_get_order($order_id);
         $payment_method = $order->payment_method;
         if (is_order_received_page() && 'tbz_voguepay_gateway' == $payment_method) {
             $voguepay_message = get_post_meta($order_id, '_tbz_voguepay_message', true);
             if (!empty($voguepay_message)) {
                 $message = $voguepay_message['message'];
                 $message_type = $voguepay_message['message_type'];
                 delete_post_meta($order_id, '_tbz_voguepay_message');
                 wc_add_notice($message, $message_type);
             }
         }
     }
 }
 public function inicis_order_received_title($title, $id)
 {
     if (is_order_received_page() && get_the_ID() === $id) {
         global $wp;
         $order_id = apply_filters('woocommerce_thankyou_order_id', absint($wp->query_vars['order-received']));
         $order_key = apply_filters('woocommerce_thankyou_order_key', empty($_GET['key']) ? '' : wc_clean($_GET['key']));
         if (!empty($order_id)) {
             $order = new WC_Order($order_id);
             if ($order->get_status() == 'failed') {
                 $title = __('결제 실패로, 결제를 다시한번 진행 해 주시기 바랍니다.', 'inicis_payment');
             } else {
                 $title = __('정상적인 결제완료로 주문이 접수되었습니다.', 'inicis_payment');
             }
         } else {
             $title = __('정상적인 결제완료로 주문이 접수되었습니다.', 'inicis_payment');
         }
     }
     return $title;
 }
Ejemplo n.º 18
0
wp_head();
?>
</head>
<?php 
$class_name = 'header--sticky';
if (wpgrade::option('nav_always_show')) {
    $class_name .= '  nav-scroll-show';
} else {
    $class_name .= '  nav-scroll-hide';
}
$data_smoothscrolling = wpgrade::option('use_smooth_scroll') == 1 ? 'data-smoothscrolling' : '';
$data_main_color = wpgrade::option('main_color') ? 'data-color="' . wpgrade::option('main_color') . '"' : '';
//first let's test if we are in woocommerce
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
    //we need to setup post data
    if (is_shop() || is_cart() || is_checkout() || is_checkout_pay_page() || is_account_page() || is_order_received_page()) {
        $shop_page_id = wc_get_page_id('shop');
        if (!empty($shop_page_id) && $shop_page_id != 0) {
            global $post;
            $post = get_post($shop_page_id);
            setup_postdata($post);
            $make_transparent_menu_bar = get_post_meta(wpgrade::lang_page_id(get_the_ID()), wpgrade::prefix() . 'header_transparent_menu_bar', true);
            if ($make_transparent_menu_bar == 'on') {
                $class_name .= '  header--transparent';
            }
        }
    }
}
//make the header menu bar transparent
//only for static pages
if (is_page()) {
Ejemplo n.º 19
0
 /**
  * Add body classes.
  *
  * @access public
  * @return void
  */
 public function wp_head()
 {
     if (is_woocommerce()) {
         $this->add_body_class('woocommerce');
         $this->add_body_class('woocommerce-page');
         return;
     }
     if (is_checkout() || is_order_received_page()) {
         $this->add_body_class('woocommerce-checkout');
         $this->add_body_class('woocommerce-page');
         return;
     }
     if (is_cart()) {
         $this->add_body_class('woocommerce-cart');
         $this->add_body_class('woocommerce-page');
         return;
     }
     if (is_account_page()) {
         $this->add_body_class('woocommerce-account');
         $this->add_body_class('woocommerce-page');
         return;
     }
 }
Ejemplo n.º 20
0
 /**
  * Returns correct title for WooCommerce pages.
  *
  * @since 2.0.0
  */
 public static function title_config($title)
 {
     // Shop title
     if (is_shop()) {
         $title = get_the_title(wc_get_page_id('shop'));
         $title = $title ? $title : ($title = esc_html__('Shop', 'total'));
     } elseif (is_product()) {
         $title = wpex_get_translated_theme_mod('woo_shop_single_title');
         $title = $title ? $title : esc_html__('Shop', 'total');
     } elseif (is_order_received_page()) {
         $title = esc_html__('Order Received', 'total');
     }
     // Return title
     return $title;
 }
 function append_query_parameters($parameters)
 {
     if (is_order_received_page() || is_checkout()) {
         if (!in_array('order', $parameters)) {
             $parameters[] = 'order';
         }
         if (!in_array('key', $parameters)) {
             $parameters[] = 'key';
         }
     }
     return $parameters;
 }
Ejemplo n.º 22
0
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
/**
 * @see yit_slogan_background() For style css
 */
$show_slogan = YIT_Layout()->show_slogan;
$slogan = YIT_Layout()->slogan;
$subslogan = YIT_Layout()->sub_slogan;
if ((empty($show_slogan) || $show_slogan == 'no') && function_exists('WC')) {
    if (is_cart() && sizeof(WC()->cart->get_cart()) != 0 || is_checkout() || is_order_received_page()) {
        $slogan_class = 'yit-cart-checkout-slogan';
        $show_slogan = YIT_Layout()->checkout_show_slogan;
        $slogan_text = array('cart' => YIT_Layout()->checkout_cart_text, 'checkout' => YIT_Layout()->checkout_text, 'order_complete' => YIT_Layout()->checkout_order_complete_text);
        ob_start();
        ?>
        <span class="slogan-cart"><?php 
        echo $slogan_text['cart'];
        ?>
</span>
        <span class="slogan-checkout"><?php 
        echo $slogan_text['checkout'];
        ?>
</span>
        <span class="slogan-complete"><?php 
        echo $slogan_text['order_complete'];
function mb_is_woocommerce_page()
{
    $is_woocommerce = false;
    if (class_exists('Woocommerce')) {
        if (is_woocommerce() || is_shop() || is_product_category() || is_product_taxonomy() || is_product_tag() || is_product() || is_cart() || is_checkout() || is_order_received_page() || is_account_page() || is_ajax()) {
            $is_woocommerce = true;
        }
    }
    return $is_woocommerce;
}
Ejemplo n.º 24
0
 /**
  * everything_author_bio_display, everything_social_buttons_display, everything_meta_display filter
  *
  * @internal filter: everything_author_bio_display
  * @internal filter: everything_social_buttons_display
  * @internal filter: everything_meta_display
  * @since 1.0
  *
  * @param  bool $show
  * @return bool
  */
 public function filterWoocommerceEverythingDisplay($show)
 {
     if (Everything::isPluginActive('woocommerce') && (is_cart() || is_checkout() || is_account_page() || is_order_received_page())) {
         return false;
     }
     return $show;
 }
 function alphabank_message()
 {
     $order_id = absint(get_query_var('order-received'));
     $order = new WC_Order($order_id);
     $payment_method = $order->payment_method;
     if (is_order_received_page() && 'alphabank_gateway' == $payment_method) {
         $alphabank_message = get_post_meta($order_id, '_alphabank_message', true);
         $message = $alphabank_message['message'];
         $message_type = $alphabank_message['message_type'];
         delete_post_meta($order_id, '_alphabank_message');
         if (!empty($alphabank_message)) {
             wc_add_notice($message, $message_type);
         }
     }
 }
Ejemplo n.º 26
0
    $tpl_default_settings = is_array($tpl_default_settings) ? $tpl_default_settings : array();
    if (!array_key_exists("disable-everywhere-sidebar", $tpl_default_settings)) {
        if (function_exists('dynamic_sidebar') && dynamic_sidebar('display-everywhere-sidebar')) {
        }
    }
}
if ("product" === get_post_type() and is_post_type_archive('product')) {
    display_everywhere_sidebar(get_option('woocommerce_shop_page_id'));
    shop_sidebar('page-' . get_option('woocommerce_shop_page_id') . '-sidebar');
} elseif (class_exists('woocommerce') && is_product_category()) {
    shop_sidebar('product-category-' . get_query_var('product_cat') . '-sidebar');
} elseif (class_exists('woocommerce') && is_product_tag()) {
    shop_sidebar('product-tag-' . get_query_var('product_tag') . '-sidebar');
} elseif (is_singular('product')) {
    shop_sidebar('product-' . $post->ID . '-sidebar');
} elseif (class_exists('woocommerce') && (is_cart() || is_checkout() || is_order_received_page() || is_account_page())) {
    display_everywhere_sidebar($post->ID);
    shop_sidebar('page-' . $post->ID . '-sidebar');
} elseif (class_exists('woocommerce') && is_page(get_option('woocommerce_change_password_page_id'))) {
    display_everywhere_sidebar(get_option('woocommerce_change_password_page_id'));
    shop_sidebar('page-' . get_option('woocommerce_change_password_page_id') . '-sidebar');
} elseif (class_exists('woocommerce') && is_page(get_option('woocommerce_edit_address_page_id'))) {
    display_everywhere_sidebar(get_option('woocommerce_edit_address_page_id'));
    shop_sidebar('page-' . get_option('woocommerce_edit_address_page_id') . '-sidebar');
} elseif (class_exists('woocommerce') && is_page(get_option('woocommerce_view_order_page_id'))) {
    display_everywhere_sidebar(get_option('woocommerce_view_order_page_id'));
    shop_sidebar('page-' . get_option('woocommerce_view_order_page_id') . '-sidebar');
} elseif (is_category()) {
    if (function_exists('dynamic_sidebar') && dynamic_sidebar('category-' . get_query_var('cat') . '-sidebar')) {
    } else {
        if (function_exists('dynamic_sidebar') && dynamic_sidebar('display-everywhere-sidebar')) {
 function order_received_title($title, $id)
 {
     if (is_order_received_page() && get_the_ID() === $id) {
         $alternative_text = wskl_get_option('thankyou_page_title_text');
         if (!empty($alternative_text)) {
             return $alternative_text;
         }
     }
     return $title;
 }
 /**
  * Check if we are on a woocommerce page
  *
  * @return bool
  */
 function wolf_is_woocommerce()
 {
     if (class_exists('Woocommerce')) {
         if (is_woocommerce()) {
             return true;
         }
         if (is_shop()) {
             return true;
         }
         if (is_checkout() || is_order_received_page()) {
             return true;
         }
         if (is_cart()) {
             return true;
         }
         if (is_account_page()) {
             return true;
         }
     }
 }
Ejemplo n.º 29
0
<?php

get_header();
$cb_page_id = get_the_ID();
$cb_breadcrumbs = ot_get_option('cb_breadcrumbs', 'on');
$cb_theme_style = ot_get_option('cb_theme_style', 'cb_boxed');
$cb_page_base_color = get_post_meta($cb_page_id, 'cb_overall_color_post', true);
$cb_page_featured_style = get_post_meta($cb_page_id, 'cb_page_featured_style', true);
$cb_page_comments = get_post_meta($cb_page_id, 'cb_page_comments', 'off');
if ($cb_page_base_color == '#' || $cb_page_base_color == NULL) {
    $cb_page_base_color = ot_get_option('cb_base_color', '#eb9812');
}
if (class_exists('Woocommerce') && (is_cart() == true || is_checkout() == true || is_order_received_page() == true || is_account_page() == true)) {
    $cb_page_base_color = ot_get_option('cb_woocommerce_global_color', '#eb9812');
}
if ($cb_page_featured_style == NULL || $cb_page_featured_style == '4' || $cb_page_featured_style == '5') {
    echo cb_featured_image($post, 'page');
}
?>
        <div id="cb-content" class="wrap clearfix">

	        <div class="cb-cat-header" style="border-bottom-color:<?php 
echo $cb_page_base_color;
?>
;">

	                <h1 id="cb-cat-title" ><?php 
echo the_title();
?>
</h1>
 /**
  * Handles the subscription upgrade/downgrade process.
  *
  * @since 1.4
  */
 public static function subscription_switch_handler()
 {
     global $post;
     // If the current user doesn't own the subscription, remove the query arg from the URL
     if (isset($_GET['switch-subscription'])) {
         $subscription = wcs_get_subscription($_GET['switch-subscription']);
         // Visiting a switch link for someone elses subscription or if the switch link doesn't contain a valid nonce
         if (!is_object($subscription) || !current_user_can('switch_shop_subscription', $subscription->id) || empty($_GET['_wcsnonce']) || !wp_verify_nonce($_GET['_wcsnonce'], 'wcs_switch_request') || 'no' === get_option(WC_Subscriptions_Admin::$option_prefix . '_allow_switching', 'no')) {
             wp_redirect(remove_query_arg(array('switch-subscription', 'auto-switch', 'item', '_wcsnonce')));
             exit;
         } else {
             if (isset($_GET['auto-switch'])) {
                 $switch_message = __('You have a subscription to this product. Choosing a new subscription will replace your existing subscription.', 'woocommerce-subscriptions');
             } else {
                 $switch_message = __('Choose a new subscription.', 'woocommerce-subscriptions');
             }
             WC_Subscriptions::add_notice($switch_message, 'notice');
         }
     } elseif ((is_cart() || is_checkout()) && !is_order_received_page() && false !== ($switch_items = self::cart_contains_switches())) {
         $removed_item_count = 0;
         foreach ($switch_items as $cart_item_key => $switch_item) {
             $subscription = wcs_get_subscription($switch_item['subscription_id']);
             if (!is_object($subscription) || !current_user_can('switch_shop_subscription', $subscription->id) || !wcs_is_product_switchable_type(WC()->cart->cart_contents[$cart_item_key]['data'])) {
                 WC()->cart->remove_cart_item($cart_item_key);
                 $removed_item_count++;
             }
         }
         if ($removed_item_count > 0) {
             WC_Subscriptions::add_notice(_n('Your cart contained an invalid subscription switch request. It has been removed.', 'Your cart contained invalid subscription switch requests. They have been removed.', $removed_item_count, 'woocommerce-subscriptions'), 'error');
             wp_redirect(WC()->cart->get_cart_url());
             exit;
         }
     } elseif (is_product() && ($product = wc_get_product($post))) {
         // Automatically initiate the switch process for limited variable subscriptions
         if (wcs_is_product_switchable_type($product) && 'no' != $product->limit_subscriptions) {
             // Check if the user has an active subscription for this product, and if so, initiate the switch process
             $subscriptions = wcs_get_users_subscriptions();
             $child_ids = $product->get_children();
             foreach ($subscriptions as $subscription) {
                 // If we're on a grouped product's page, we need to check if the subscription has a child of this grouped product that needs to be switched
                 $subscription_product_id = false;
                 if ($product->is_type('grouped')) {
                     foreach ($child_ids as $child_id) {
                         if ($subscription->has_product($child_id)) {
                             $subscription_product_id = $child_id;
                             break;
                         }
                     }
                 }
                 if ($subscription->has_product($product->id) || $subscription_product_id) {
                     // For grouped products, we need to check the child products limitations, not the grouped product's (which will have no limitation)
                     if ($subscription_product_id) {
                         $child_product = wc_get_product($subscription_product_id);
                         $limitation = $child_product->limit_subscriptions;
                     } else {
                         $limitation = $product->limit_subscriptions;
                     }
                     // If the product is limited
                     if ('any' == $limitation || $subscription->has_status($limitation) || 'active' == $limitation && $subscription->has_status('on-hold')) {
                         $subscribed_notice = __('You have already subscribed to this product and it is limited to one per customer. You can not purchase the product again.', 'woocommerce-subscriptions');
                         // If switching is enabled for this product type, initiate the auto-switch process
                         if (wcs_is_product_switchable_type($product)) {
                             // Don't initiate auto-switching when the subscription requires payment
                             if ($subscription->needs_payment()) {
                                 $last_order = $subscription->get_last_order('all');
                                 if ($last_order->needs_payment()) {
                                     // translators: 1$: is the "You have already subscribed to this product" notice, 2$-4$: opening/closing link tags, 3$: an order number
                                     $subscribed_notice = sprintf(__('%1$s Complete payment on %2$sOrder %3$s%4$s to be able to change your subscription.', 'woocommerce-subscriptions'), $subscribed_notice, sprintf('<a href="%s">', $last_order->get_checkout_payment_url()), $last_order->get_order_number(), '</a>');
                                 }
                                 WC_Subscriptions::add_notice($subscribed_notice, 'notice');
                                 break;
                             } else {
                                 $product_id = $subscription_product_id ? $subscription_product_id : $product->id;
                                 // Get the matching item
                                 foreach ($subscription->get_items() as $line_item_id => $line_item) {
                                     if ($line_item['product_id'] == $product_id || $line_item['variation_id'] == $product_id) {
                                         $item_id = $line_item_id;
                                         $item = $line_item;
                                         break;
                                     }
                                 }
                                 wp_redirect(add_query_arg('auto-switch', 'true', self::get_switch_url($item_id, $item, $subscription)));
                                 exit;
                             }
                         } else {
                             WC_Subscriptions::add_notice($subscribed_notice, 'notice');
                             break;
                         }
                     }
                 }
             }
         }
     }
 }