Skip to content

Instantly share code, notes, and snippets.

View EricBusch's full-sized avatar

Eric Busch EricBusch

  • Owen Sound, Ontario
View GitHub Profile
<?php
$search = $api->searchRequest();
$search->addFilter('category LIKE [trail]');
$products = $search->execute();
<?php
$search = $api->searchRequest();
$search->addFilter('ANY LIKE shoes');
$search->excludeDuplicates('image');
$products = $search->execute();
<?php
$search = $api->searchRequest();
$search->addFilter('ANY LIKE shoes');
$search->excludeDuplicates('merchant_id name price');
$products = $search->execute();
<?php
$networks = $api->getNetworks( array(), FALSE, array( '_id', 'name' ) );
foreach( $networks as $network ) {
echo 'Network ID: ' . $network['_id'];
echo 'Network Name: ' . $network['name'];
}
<?php
$merchants = $api->getMerchants( array( 6, 8, 3, 4 ), FALSE, array( '_id', 'name' ) );
foreach( $merchants as $merchant ) {
echo "Merchant: " . $merchant['name'] . "(" . $merchant['_id'] . ")\n";
}
<?php
$merchants = $api->getMerchantsById( array( 42742, 675, 4203, 677 ), FALSE, array( '_id', 'name', 'product_count' ) );
foreach( $merchants as $merchant ) {
echo $merchant['name'];
echo " (ID: " . $merchant['_id'] . ") ";
echo number_format( $merchant['product_count'] );
echo " product<br />";
}
<?php
$api = new DatafeedrApi(MY_ACCESS_ID, MY_SECRET_KEY, 'curl');
$search = $api->amazonSearchRequest(MY_AMAZON_ACCESS_KEY, MY_AMAZON_SECRET_KEY, MY_AMAZON_ASSOCIATE_TAG, "US");
$search->addParam('Brand', 'nike');
$search->addParam('Keywords', 'shoe golf');
$search->addParam('MaximumPrice', '1500');
$search->addParam('SearchIndex', 'Apparel');
<?php
$search = $api->searchRequest();
$search->addFilter( 'salediscount > 20' );
$products = $search->execute();
@EricBusch
EricBusch / replace-buy-button-with-more-details.php
Created January 22, 2014 15:35
Replaces "Buy" button with "More Details" button on list of products (WooCommerce). For example on category pages.
<?php
/**
* Removes the "Buy" button from list of products (ex. category pages).
*/
add_action( 'woocommerce_after_shop_loop_item', 'mycode_remove_add_to_cart_buttons', 1 );
function mycode_remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
@EricBusch
EricBusch / sort-by-discount.php
Created February 4, 2014 21:09
Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount.
<?php
/**
* Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount.
*/
add_filter( 'woocommerce_get_catalog_ordering_args', 'mycode_woocommerce_add_salediscount_to_catalog_ordering_args' );
function mycode_woocommerce_add_salediscount_to_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'discount' == $orderby_value ) {
$args['orderby'] = 'meta_value_num';