autoship_total_product_summary_data

(src/products.php) In the autoship_get_product_sync_summary() function, and allows developers to use the QPilot API response in functions filtering the summary data. Takes the totals array and product array as parameters

$totals = array();
  if ( 'variation' == $product->get_type() || 'simple' == $product->get_type() ){

    $totals = apply_filters( 'autoship_product_summary_data', array(
      'Id'                            => $summaries[0]->Id,
      'ExternalId'                    => $summaries[0]->ExternalId,
      'ProductName'                   => $summaries[0]->ProductName,
      'AddToScheduledOrder'           => strpos($summaries[0]->Availability, 'AddToScheduledOrder') !== false,
      'ProcessScheduledOrder'         => strpos($summaries[0]->Availability, 'ProcessScheduledOrder') !== false,
      'Availability'                  => $summaries[0]->Availability,
      'ProductType'                   => $summaries[0]->ProductType,
      'StockLevel'                    => $summaries[0]->StockLevel,
      'TotalStock'                    => $summaries[0]->Stock,
      'QuantityScheduled'             => $summaries[0]->TotalQuantityScheduledActive +
                                         $summaries[0]->TotalQuantityScheduledPaused +
                                         $summaries[0]->TotalQuantityFailed +
                                         $summaries[0]->TotalQuantityProcessing +
                                         $summaries[0]->TotalQuantityQueued,
      'TotalQuantityScheduledActive'  => $summaries[0]->TotalQuantityScheduledActive,
      'TotalQuantityScheduledPaused'  => $summaries[0]->TotalQuantityScheduledPaused,
      'TotalQuantityFailed'           => $summaries[0]->TotalQuantityFailed,
      'TotalQuantityProcessing'       => $summaries[0]->TotalQuantityProcessing,
      'TotalQuantityQueued'           => $summaries[0]->TotalQuantityQueued,
      'LifetimeValue'                 => $summaries[0]->LifetimeValue,
      'ShippingClass'                 => $summaries[0]->ShippingClass,
      'Active'                        => $summaries[0]->Active,
      'Valid'                         => $summaries[0]->Valid,
      'ValidationErrorCode'           => $summaries[0]->ValidationErrorCode,
      'UpdatedUtc'                    => $summaries[0]->UpdatedUtc,
      'SyncError'                     => ''
    ), $summaries[0], $product );

    // Since we've already pulled the Active flag from QPilot get the flag from WooCommerce / Autoship
    $totals['AutoshipActive'] = ( 'yes' === autoship_sync_active_enabled( $product ) );

    // Run Sync Checks
    $totals['SyncError'] = apply_filters( 'autoship_product_summary_data_sync_error', $totals['SyncError'], $totals, $summaries[0], $product, $ids );

    return apply_filters( 'autoship_total_product_summary_data', $totals, $product, $summaries );

Still need help? Contact Us Contact Us