• Resolved vgstudios

    (@vgstudios)


    Thank you very much for your plugin.

    I just wanted to share some functions.php code, in case someone else has similar problems:

    <?php
    /* Custom functions code goes here. */
    
    add_action( 'wc_zap_mirror_xml_node', 'adel_wc_zap_mirror_xml_node', 20, 3);
    function adel_wc_zap_mirror_xml_node(&$node, $product, $post) {
    
    	$node->PRODUCT_URL = wp_get_shortlink($product->get_id());
    	
    	WC()->shipping()->reset_shipping();
        WC()->customer->set_billing_address_to_base();
        WC()->customer->set_shipping_address_to_base();
    	
    	WC()->customer->set_billing_country( 'IL' );
    	WC()->customer->set_shipping_country( 'IL' );
    	WC()->session->set( 'chosen_shipping_methods', array(1) );	
    	WC()->cart->empty_cart();
    	WC()->cart->add_to_cart($product->get_id(), 1);
    	
    	$packages = WC()->cart->get_shipping_packages();
    	$shipping = WC()->shipping->calculate_shipping($packages);
    	$packages = WC()->shipping->get_packages();
    	
    	$shipping_costs = null;
    	
    	if(!empty($packages) && isset($packages[0]) && isset($packages[0]['rates']))
    	{	
    		foreach($packages[0]['rates'] as $rate)
    		{
    			if($shipping_costs === null || $rate < $shipping_costs)
    				$shipping_costs = $rate->get_cost() + $rate->get_shipping_tax();
    		}
    	}
    	
    	if($shipping_costs === null) $shipping_costs = 1000;
    	
    	$node->SHIPMENT_COST = $shipping_costs;	
    
    	WC()->cart->empty_cart();
    	
    	$node->DETAILS = wp_strip_all_tags(strip_shortcodes($node->DETAILS));
    	
    	if($product->is_on_sale())
    		$node->PRICE = $product->get_sale_price();
    	else
    		$node->PRICE = $product->get_price();
    }

    This code currently fulfills our requirements, but might not be the right fit for everyone!

    – Use short URL as recommended.
    – Some simple shipping costs calculation (this will probably not fit all people, e.g. if they have different areas to deliver to).
    – Strip HTML tags from product DETAILS, as recommended.
    – Checks if product is on sale, if yes sale price, otherwise normal price

    https://img.zap.co.il/PDFs/ZapTechnicalRequirements.pdf

    Again thank you for your plugin, have a great day, ????

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Thank you / some code’ is closed to new replies.