• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / edd_v20_upgrade_sequential_payment_numbers() – Upgrades for EDD v2.0 and sequential payment numbers

You appear to be a bot. Output may be restricted

Description

Upgrades for EDD v2.0 and sequential payment numbers

Usage

$void = edd_v20_upgrade_sequential_payment_numbers();

Parameters

Returns

void

Source

File name: easy-digital-downloads/includes/admin/upgrades/upgrade-functions.php
Lines:

1 to 72 of 72
function edd_v20_upgrade_sequential_payment_numbers() {

  if( ! current_user_can( 'manage_shop_settings' ) ) {
    wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
  }

  ignore_user_abort( true );

  if ( ! edd_is_func_disabled( 'set_time_limit' ) ) {
    set_time_limit( 0 );
  }

  $step   = isset( $_GET['step'] )  ? absint( $_GET['step'] )  : 1;
  $total  = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false;

  if( empty( $total ) || $total <= 1 ) {
    $payments = edd_count_payments();
    foreach( $payments as $status ) {
      $total += $status;
    }
  }

  $args   = array(
    'number' => 100,
    'page'   => $step,
    'status' => 'any',
    'order'  => 'ASC'
  );

  $payments = new EDD_Payments_Query( $args );
  $payments = $payments->get_payments();

  if( $payments ) {

    $prefix  = edd_get_option( 'sequential_prefix' );
    $postfix = edd_get_option( 'sequential_postfix' );
    $number  = ! empty( $_GET['custom'] ) ? absint( $_GET['custom'] ) : intval( edd_get_option( 'sequential_start', 1 ) );

    foreach( $payments as $payment ) {

      // Re-add the prefix and postfix
      $payment_number = $prefix . $number . $postfix;

      edd_update_payment_meta( $payment->ID, '_edd_payment_number', $payment_number );

      // Increment the payment number
      $number++;

    }

    // Payments found so upgrade them
    $step++;
    $redirect = add_query_arg( array(
      'page'        => 'edd-upgrades',
      'edd-upgrade' => 'upgrade_sequential_payment_numbers',
      'step'        => $step,
      'custom'      => $number,
      'total'       => $total
    ), admin_url( 'index.php' ) );
    wp_redirect( $redirect ); exit;

  } else {


    // No more payments found, finish up
    EDD()->session->set( 'upgrade_sequential', null );
    delete_option( 'edd_doing_upgrade' );

    wp_redirect( admin_url() ); exit;
  }

}
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 26th November 2019

Primary Sidebar

Information

Function name: edd_v20_upgrade_sequential_payment_numbers
Plugin ref: Easy Digital Downloads
Version: 2.9.23
Sourcefile: includes/admin/upgrades/upgrade-functions.php
File ref: includes/admin/upgrades/upgrade-functions.php
Deprecated?: No
API Letters: E,P,S,U,V

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites