Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.3 kB
1
Indexable
Never
add_action('marketking_after_order_details_text', function(){

	$order_id = sanitize_text_field(marketking()->get_pagenr_query_var());
	$order = wc_get_order($order_id);

    $order_status  = $order->get_status();
    		$approve_class 	= '';
    		$reject_class	= '';
    		$aprv_btn_visibility_cls = '';

    		if ($order->get_status() == 'waiting') {
    			$approve_label  =	 __('Approve', 'order-approval-woocommerce');
    		} else {
    			$approve_label  =	 __('Approved', 'order-approval-woocommerce');
    			$approve_class = 'approved';
    		}
    		if ($order->get_status() == 'cancelled') {
    			$reject_class = 'reject';
    			$aprv_btn_visibility_cls = 'oa_btn_visibility';
    			$reject_label   = 	__('Rejected', 'order-approval-woocommerce');
    		} else {
    			$reject_label   = 	__('Reject', 'order-approval-woocommerce');
    		}


    		$approve_slug   =	wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce_mark_order_status&status=pending&order_id=' . $order->get_id()), 'woocommerce-mark-order-status');
    		$reject_slug	=	wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce_mark_order_status&status=cancelled&order_id=' . $order->get_id()), 'woocommerce-mark-order-status');
    ?>
    		<a href="<?php echo $approve_slug; ?>" class="button success <?php echo $approve_class . " " . $aprv_btn_visibility_cls; ?>">
    			<?php echo $approve_label; ?>
    		</a>
    		<a href="<?php echo $reject_slug; ?>" class="button danger <?php echo $reject_class; ?>">
    			<?php echo $reject_label; ?>
    		</a>
    		<style>
    			.button.danger {
    				color: red;
    				border-color: red;
    			}

    			.button.danger:hover {
    				color: red;
    				border-color: red;
    			}

    			.button.success {
    				color: green;
    				border-color: green;
    			}

    			.button.success:hover {
    				color: green;
    				border-color: green;
    			}

    			.approved:before {
    				content: "\f12a";
    				font: normal 15px/1 'dashicons';
    				vertical-align: middle;

    			}

    			.reject:before {
    				content: "\f153";
    				font: normal 15px/1 'dashicons';
    				vertical-align: middle;

    			}

    			.oa_btn_visibility {
    				display: none !important
    			}
    		</style>
    	<?php
});