• 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_Batch_Payments_Import::create_payment() – Set up and store a payment record from a CSV row

You appear to be a bot. Output may be restricted

Description

Set up and store a payment record from a CSV row

Usage

$void = EDD_Batch_Payments_Import::create_payment( $row );

Parameters

$row
( mixed ) optional –

Returns

void

Source

File name: easy-digital-downloads/includes/admin/import/class-batch-import-payments.php
Lines:

101 to 200 of 260
    if( ! empty( $this->field_mapping['transaction_id'] ) && ! empty( $row[ $this->field_mapping['transaction_id'] ] ) ) {

      $payment->transaction_id = sanitize_text_field( $row[ $this->field_mapping['transaction_id'] ] );

    }

    if( ! empty( $this->field_mapping['ip'] ) && ! empty( $row[ $this->field_mapping['ip'] ] ) ) {

      $payment->ip = sanitize_text_field( $row[ $this->field_mapping['ip'] ] );

    }

    if( ! empty( $this->field_mapping['gateway'] ) && ! empty( $row[ $this->field_mapping['gateway'] ] ) ) {

      $gateways = edd_get_payment_gateways();
      $gateway  = strtolower( sanitize_text_field( $row[ $this->field_mapping['gateway'] ] ) );

      if( ! array_key_exists( $gateway, $gateways ) ) {

        foreach( $gateways as $key => $enabled_gateway ) {

          if( $enabled_gateway['checkout_label'] == $gateway ) {

            $gateway = $key;
            break;

          }

        }

      }

      $payment->gateway = $gateway;

    }

    if( ! empty( $this->field_mapping['currency'] ) && ! empty( $row[ $this->field_mapping['currency'] ] ) ) {

      $payment->currency = strtoupper( sanitize_text_field( $row[ $this->field_mapping['currency'] ] ) );

    }

    if( ! empty( $this->field_mapping['key'] ) && ! empty( $row[ $this->field_mapping['key'] ] ) ) {

      $payment->key = sanitize_text_field( $row[ $this->field_mapping['key'] ] );

    }

    if( ! empty( $this->field_mapping['parent_payment_id'] ) && ! empty( $row[ $this->field_mapping['parent_payment_id'] ] ) ) {

      $payment->parent_payment_id = absint( $row[ $this->field_mapping['parent_payment_id'] ] );

    }

    if( ! empty( $this->field_mapping['downloads'] ) && ! empty( $row[ $this->field_mapping['downloads'] ] ) ) {

      if( __( 'Products (Raw)', 'easy-digital-downloads' ) == $this->field_mapping['downloads'] ) {

        // This is an EDD export so we can extract prices
        $downloads = $this->get_downloads_from_edd( $row[ $this->field_mapping['downloads'] ] );

      } else {

        $downloads = $this->str_to_array( $row[ $this->field_mapping['downloads'] ] );

      }

      if( is_array( $downloads ) ) {

        $download_count = count( $downloads );

        foreach( $downloads as $download ) {

          if( is_array( $download ) ) {
            $download_name = $download['download'];
            $price         = $download['price'];
            $tax           = $download['tax'];
            $price_id      = $download['price_id'];
          } else {
            $download_name = $download;
          }

          $download_id = $this->maybe_create_download( $download_name );

          if( ! $download_id ) {
            continue;
          }

          $item_price = ! isset( $price ) ? edd_get_download_price( $download_id ) : $price;
          $item_tax   = ! isset( $tax ) ? ( $download_count > 1 ? 0.00 : $payment->tax ) : $tax;
          $price_id   = ! isset( $price_id ) ? false : $price_id;

          $args = array(
            'item_price' => $item_price,
            'tax'        => $item_tax,
            'price_id'   => $price_id,
          );

          $payment->add_download( $download_id, $args );

 
« Previous [1] [2] [3] Next »

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 13th March 2021

Primary Sidebar

Information

Function name: EDD_Batch_Payments_Import::create_payment
Class ref: EDD_Batch_Payments_Import
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/admin/import/class-batch-import-payments.php
File ref: includes/admin/import/class-batch-import-payments.php
Deprecated?: No
API Letters: B,C,E,I,P

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
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-2022. All rights reserved.


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

  • Home
  • Blog
  • Sitemap
  • Sites