וורדפרס ואתרי אינטרנט

owl-158414_960_720
דורג 5 מתוך 5

באתר תמצאו מדריכים ומאמרים ייחודים בעברית, המדריכים לרוב מנסיון מעשי ומיוחסים לפרוייקטים שאני עובד עליהם באותו הזמן. האתר הוא יותר לשימוש פרטי ולתיעוד דברים, בכדי להשתמש מאוחר יותר, אבל החלטתי לפרסם ניתן לשאול כל שאלה וגם לתרום מדריכים באתר דרך תגובה או דרך צור קשר

הוק לדף תודה של ווקומרס הסקריפט פה שולח את פרטי ההזמנה וכו..

<?php
/**
 * This is a PHP code, so should be wrapped inside PHP
 * Like we added here.
 * If PHP is already open then don't include above <?php open tag
 */
/**
 * Adding custom javascripts or php action on WooCommerce Thank you page
 * Works with WooCommerce 3.0 or above
 */
add_action( "woocommerce_thankyou", "xlwcty_thank_you_script", 20 );

if ( ! function_exists( 'xlwcty_thank_you_script' ) ) {
	function xlwcty_thank_you_script( $order_id ) {
		if ( $order_id > 0 ) {
			$order = wc_get_order( $order_id );
			if ( $order instanceof WC_Order ) {
				$order_id               = $order->get_id(); // order id
				$order_key              = $order->get_order_key(); // order key
				$order_total            = $order->get_total(); // order total
				$order_currency         = $order->get_currency(); // order currency
				$order_payment_method   = $order->get_payment_method(); // order payment method
				$order_shipping_country = $order->get_shipping_country(); // order shipping country
				$order_billing_country  = $order->get_billing_country(); // order billing country
				$order_status           = $order->get_status(); // order status
				/**
				 * full list methods and property that can be accessed from $order object
				 * https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html
				 */
				?>
                <script type="text/javascript">
                    // write custom action here
                </script>
				<?php
			}
		}
	}
}

/**
 * This code execute inside head tag
 */
add_action( "wp_head", "xlwcty_thank_you_header_script", 20 );

if ( ! function_exists( 'xlwcty_thank_you_header_script' ) ) {
	function xlwcty_thank_you_header_script() {
		if ( function_exists( 'is_order_received_page' ) && is_order_received_page() && isset( $_GET['order_id'] ) ) {
			$order_id = $_GET['order_id'];
			$order    = wc_get_order( $order_id );
			if ( $order instanceof WC_Order ) {
				$order_id               = $order->get_id(); // order id
				$order_key              = $order->get_order_key(); // order key
				$order_total            = $order->get_total(); // order total
				$order_currency         = $order->get_currency(); // order currency
				$order_payment_method   = $order->get_payment_method(); // order payment method
				$order_shipping_country = $order->get_shipping_country(); // order shipping country
				$order_billing_country  = $order->get_billing_country(); // order billing country
				$order_status           = $order->get_status(); // order status
				/**
				 * full list methods and property that can be accessed from $order object
				 * https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html
				 */
				?>
                <script type="text/javascript">
                    // write custom action here
                </script>
				<?php
			}
		}
	}
}

תפריט נגישות