php Gravity Perks // GP电子商务领域//从订单摘要中扣除存款

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Gravity Perks // GP电子商务领域//从订单摘要中扣除存款相关的知识,希望对你有一定的参考价值。

<?php
/**
 * Gravity Perks // GP eCommerce Fields // Deduct Deposit from Order Summary
 * http://gravitywiz.com/documentation/gravity-forms-ecommerce-fields/
 */
add_action( 'wp_loaded', function() {

	if( ! function_exists( 'gp_ecommerce_fields' ) ) {
		return;
	}

	remove_action( 'gform_product_info', array( gp_ecommerce_fields(), 'add_ecommerce_fields_to_order' ), 9, 3 );
	add_action( 'gform_product_info', function( $order, $form, $entry ) {

		// CHANGE: Update "123" to the ID of your form.
		if( $form['id'] != 123 ) {
			return gp_ecommerce_fields()->add_ecommerce_fields_to_order( $order, $form, $entry );
		}

		// CHANGE: Update the "2" to your deposit field ID.
		$deposit =& $order['products'][2];

		// Run this first so calculations are reprocessed before we convert deposit to a negative number.
		$order = gp_ecommerce_fields()->add_ecommerce_fields_to_order( $order, $form, $entry );

		// Convert deposit to a negative number so it is deducted from the total.
		$deposit['price'] = GFCommon::to_money( GFCommon::to_number( $deposit['price'], $entry['currency'] ) * $deposit['quantity'] * -1, $entry['currency'] );

		// Quantity is factored into price above.
		$deposit['quantity'] = 1;

		// Set the discount flag so GP eCommerce Fields knows this is a deposit.
		$deposit['isDiscount'] = true;

		return $order;
	}, 9, 3 );

} );

以上是关于php Gravity Perks // GP电子商务领域//从订单摘要中扣除存款的主要内容,如果未能解决你的问题,请参考以下文章

php Gravity Perks // GP电子商务领域//从订单摘要中扣除存款

php Gravity Perks // GP电子商务字段//为订单摘要添加自定义总计

php Gravity Perks // GP媒体库// Ajax上传

php Gravity Perks // GP条件定价//显示价格标签

php Gravity Perks // GP限制提交//集体应用全局限制

php Gravity Perks // GP嵌套表单//从值隐藏产品名称