PHP code example of shoppingfeed / shoppingfeed-for-woocommerce

1. Go to this page and download the library: Download shoppingfeed/shoppingfeed-for-woocommerce library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shoppingfeed / shoppingfeed-for-woocommerce example snippets


add_filter( 'shopping_feed_custom_category_taxonomy', 'your_custom_category_function' );

/** @return string */
function your_custom_category_function() {
    return 'your_custom_category_slug';
}

add_filter( 'shopping_feed_custom_brand_taxonomy', 'your_custom_brand_function' );

/** @return string */
function your_custom_brand_function() {
    return 'your_custom_brand_slug';
}

add_filter( 'shopping_feed_custom_ean', 'your_custom_ean_function' );

/** @return string */
function your_custom_ean_function() {
    return 'your_custom_ean_slug';
}

add_filter( 'shopping_feed_products_custom_args', 'your_custom_args_function' );

/** @return array */
function your_custom_args_function() {
//array of args
    return array();
}

add_filter( 'shopping_feed_orders_to_import', 'your_custom_statuses_function' );

/** @return array */
function your_custom_statuses_function() {
    // array of statuses (strings)
    return array();
}

add_filter( 'shopping_feed_tracking_number', 'your_custom_tracking_number_function' );

/** @return string */
function your_custom_tracking_number_function() {
    return ‘your_custom_order_meta_key’
}

add_filter( 'shopping_feed_tracking_link', 'your_custom_tracking_url_function' );

/** @return string */
function your_custom_tracking_url_function() {
    return ‘your_custom_order_meta_key’
}

add_filter( 'shopping_feed_extra_fields', 'your_custom_fields_function', 10, 2 );

/** @return array */
function your_custom_fields_function($fields, $wc_product) {
    $fields[] = array('name'=>'my_field', 'value'=>'my_value');
    return $fields;
}

add_filter( 'shopping_feed_variation_images', 'your_custom_variation_images_function', 10, 3 );

/** 
 * @param array $images
 * @param WC_Product $wc_product
 * @param int $variation_id
 * 
 * @return array 
 */
function your_custom_variation_images_function( $images, $wc_product, $variation_id ) {
    $images[] = 'https://domain.com/image1.jpg';
    $images[] = 'https://domain.com/image2.jpg';
    
    return $images;
}