Skip to content

Instantly share code, notes, and snippets.

View ali-cedcoss's full-sized avatar

Ali Rizvi - 1266 ali-cedcoss

View GitHub Profile
@ali-cedcoss
ali-cedcoss / code.md
Last active May 10, 2022 04:31
indexing ebay products data locally

create a database to store the ebay products data

add_action('wp_ajax_nopriv_run_code', function(){
			global $wpdb;
			$table_name = $wpdb->prefix . 'ced_ebay_listings_data';
			$charset_collate = $wpdb->get_charset_collate();
			$sql = "CREATE TABLE IF NOT EXISTS ". $table_name . " (
				id BIGINT(20) unsigned NOT NULL,
@ali-cedcoss
ali-cedcoss / code.md
Last active May 4, 2022 13:32
eBay fulfillment API GetOrders data

orders filtered by creation date for last 3 days.

$toDate     = $currentime - ( 1 * 60 );
			$fromDate   = $currentime - ( 3 * 24 * 60 * 60 );
			$offset     = '.000Z';
			$toDate     = gmdate( 'Y-m-d', $toDate ) . 'T' . gmdate( 'H:i:s', $toDate ) . $offset;
			$fromDate   = gmdate( 'Y-m-d', $fromDate ) . 'T' . gmdate( 'H:i:s', $fromDate ) . $offset;
				$fulfillmentRequest = new Ced_Marketing_API_Request( $siteID );
				$endpoint = '?filter=creationdate:%5B'.$fromDate.'..'.$toDate.'%5D';
@ali-cedcoss
ali-cedcoss / code.md
Last active May 4, 2022 11:47
ebay fulfillment API order data
{
    "orderId": "363771570101-1313013844023",
    "legacyOrderId": "363771570101-1313013844023",
    "creationDate": "2022-05-01T17:57:00.000Z",
    "lastModifiedDate": "2022-05-03T16:22:54.000Z",
    "orderFulfillmentStatus": "FULFILLED",
    "orderPaymentStatus": "PAID",
    "sellerId": "thestonemartltd",
    "buyer": {
@ali-cedcoss
ali-cedcoss / code.md
Last active May 1, 2022 08:06
providing mapping for ebay motors categories
  • change site ID to 100 in cedGetCategories.php
  • change site ID to 100 in cedRequest.php
  • in category-mapping-view.php add this $folderName = CED_EBAY_DIRPATH . 'admin/ebay/lib/json/categoryLevel-2_' . $getLocation . '.json';
  • in category-mapping-view.php change data-level=2
@ali-cedcoss
ali-cedcoss / code.md
Last active April 25, 2022 14:13
updating variable products SKUs
public function ced_ebay_prepareProductHtmlForUpdatingSKU($proIDs = array(), $userId){
		foreach ( $proIDs as $key => $value ) {
			$prod_data        = wc_get_product( $value );
			$type             = $prod_data->get_type();
			$item_id          = get_post_meta( $value, '_ced_ebay_listing_id_' . $userId, true );
			$preparedData     = $this->getFormattedDataForUpdatingSKU( $value, $userId, $item_id );
			return $preparedData;
		}
	}
@ali-cedcoss
ali-cedcoss / code.md
Created April 22, 2022 17:15
set notification xml for sending notifications to multiple URLs
$main_xml = '<?xml version="1.0" encoding="utf-8"?>
		<SetNotificationPreferencesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
		  <RequesterCredentials>
			<eBayAuthToken>'.$token.'</eBayAuthToken>
		  </RequesterCredentials>
		  <ApplicationDeliveryPreferences>
			<AlertEmail>mailto://alirizvi@cedcommerce.com</AlertEmail>
			<AlertEnable>Enable</AlertEnable>
			<ApplicationEnable>Enable</ApplicationEnable>
@ali-cedcoss
ali-cedcoss / code.md
Last active April 17, 2022 17:07
assigning imported products to store their eBay store categories
if(!empty($itemDetails['Item']['Storefront']['StoreCategoryID'])){
						$category = $itemDetails['Item']['Storefront']['StoreCategoryID'];
										$renderDataOnGlobalSettings = ! empty( get_option( 'ced_ebay_global_settings', false ) ) ? get_option('ced_ebay_global_settings', false ) : false;
										if ( false != $renderDataOnGlobalSettings ) {
											$import_categories = $renderDataOnGlobalSettings[ $user_id ]['ced_ebay_import_ebay_categories'];
											if ( ! empty( $import_categories ) && 'Enabled' == $import_categories ) {
												if ( ! empty( $category ) ) {
													if(file_exists(CED_EBAY_DIRPATH . 'admin/ebay/lib/ebayAuthorization.php')){
@ali-cedcoss
ali-cedcoss / code.md
Last active April 15, 2022 05:39
ebay site category exclusion for imported products

###Code goes in the ced_ebay_bulk_import_to_store functin

/* Exclusion on the basis of predefined eBay Site Category */
if(!empty($itemDetails['Item']['PrimaryCategory']['CategoryID'])){
						$cedCatInstance = CedGetCategories::get_instance( $siteID, $token );
						$getCat = $cedCatInstance->_getCategoryTree( '12576' );
						$search = $itemDetails['Item']['PrimaryCategory']['CategoryID'];
 $found = array_filter($getCat['CategoryArray']['Category'],function($v,$k) use ($search){
@ali-cedcoss
ali-cedcoss / code.md
Created April 9, 2022 08:34
get all custom product attributes from db
			global $wpdb;
			$query = $wpdb->get_results($wpdb->prepare("SELECT `meta_value` FROM  {$wpdb->prefix}postmeta WHERE `meta_key` LIKE '_product_attributes'"), 'ARRAY_A');
			foreach($query as $key => $db_attribute_pair){
				foreach(maybe_unserialize($db_attribute_pair['meta_value']) as $key=>$attribute_pair){
					if(1 != $attribute_pair['is_taxonomy']){
						print_r($attribute_pair['name']);
						echo '<br>';
					}
 }
@ali-cedcoss
ali-cedcoss / code.md
Last active April 6, 2022 09:50
ebay custom profile with support for category leaf node mapping