?> "/> </p> </div> <?php } ?> <div class="edd-order-payment edd-admin-box-inside"> <p> <span class="label"><?php _e('Total Price', 'edd'); ?> :</span> <?php echo edd_currency_symbol($payment_meta['currency']); ?> <input name="edd-payment-total" type="text" class="med-text" value="<?php echo esc_attr(edd_format_amount(edd_get_payment_amount($payment_id))); ?> "/> </p> </div> <div class="edd-order-payment-recalc-totals edd-admin-box-inside" style="display:none"> <p> <span class="label"><?php _e('Recalculate Totals', 'edd'); ?> :</span> <a href="" id="edd-order-recalc-total" class="button button-secondary right"><?php
/** * Formats the currency display * * @since 1.0 * @param string $price Price * @return array $currency Currencies displayed correctly */ function edd_currency_filter($price = '', $currency = '') { if (empty($currency)) { $currency = edd_get_currency(); } $position = edd_get_option('currency_position', 'before'); $negative = $price < 0; if ($negative) { $price = substr($price, 1); // Remove proceeding "-" - } $symbol = edd_currency_symbol($currency); if ($position == 'before') { switch ($currency) { case "GBP": case "BRL": case "EUR": case "USD": case "AUD": case "CAD": case "HKD": case "MXN": case "NZD": case "SGD": case "JPY": $formatted = $symbol . $price; break; default: $formatted = $currency . ' ' . $price; break; } $formatted = apply_filters('edd_' . strtolower($currency) . '_currency_filter_before', $formatted, $currency, $price); } else { switch ($currency) { case "GBP": case "BRL": case "EUR": case "USD": case "AUD": case "CAD": case "HKD": case "MXN": case "SGD": case "JPY": $formatted = $price . $symbol; break; default: $formatted = $price . ' ' . $currency; break; } $formatted = apply_filters('edd_' . strtolower($currency) . '_currency_filter_after', $formatted, $currency, $price); } if ($negative) { // Prepend the mins sign before the currency sign $formatted = '-' . $formatted; } return $formatted; }
?> "/> </p> </div> <?php } ?> <div class="edd-order-payment edd-admin-box-inside"> <p> <span class="label"><?php _e('Total Price', 'easy-digital-downloads'); ?> :</span> <?php echo edd_currency_symbol($payment->currency); ?> <input name="edd-payment-total" type="text" class="med-text" value="<?php echo esc_attr(edd_format_amount($payment->total)); ?> "/> </p> </div> <div class="edd-order-payment-recalc-totals edd-admin-box-inside" style="display:none"> <p> <span class="label"><?php _e('Recalculate Totals', 'easy-digital-downloads'); ?> :</span> <a href="" id="edd-order-recalc-total" class="button button-secondary right"><?php
/** * Setup output data * * @access public * @since 1.0.0 * @param array $data Current output data * @param string $query_mode The called query mode * @param object $this The API object * @return array $data The updated output data */ public function output_data($data, $query_mode, $parent) { $geckoboard_data = false; switch ($query_mode) { case 'gbsaleschart': $sales_stats = $parent->get_stats(array('type' => 'sales', 'product' => null, 'date' => 'range', 'startdate' => date('Ymd', strtotime('-7 days')), 'enddate' => date('Ymd'))); foreach ($sales_stats['sales'] as $date => $sales) { $geckoboard_data['x_axis']['labels'][] = date(apply_filters('edd_geckoboard_date_format', 'm/d'), strtotime($date)); $geckoboard_sales[] = $sales; } $geckoboard_data['series'] = array(array('data' => $geckoboard_sales)); break; case 'gbearningschart': $earnings_stats = $parent->get_stats(array('type' => 'earnings', 'product' => null, 'date' => 'range', 'startdate' => date('Ymd', strtotime('-7 days')), 'enddate' => date('Ymd'))); $geckoboard_data['y_axis'] = array('format' => 'currency', 'unit' => edd_get_option('currency', 'USD')); foreach ($earnings_stats['earnings'] as $date => $earnings) { $geckoboard_data['x_axis']['labels'][] = date(apply_filters('edd_geckoboard_date_format', 'm/d'), strtotime($date)); $geckoboard_earnings[] = $earnings; } $geckoboard_data['series'] = array(array('data' => $geckoboard_earnings)); break; case 'gbsales': $geckoboard_data = array('item' => array(array('value' => (double) $this->stats->get_sales(0, 'this_month')), array('value' => (double) $this->stats->get_sales(0, 'last_month')))); break; case 'gbearnings': $geckoboard_data = array('item' => array(array('value' => edd_format_amount($this->stats->get_earnings(0, 'this_month')), 'prefix' => edd_currency_symbol(edd_get_option('currency', 'USD'))), array('value' => edd_format_amount($this->stats->get_earnings(0, 'last_month')), 'prefix' => edd_currency_symbol(edd_get_option('currency', 'USD'))))); break; case 'gbpurchases': $sales = $parent->get_recent_sales(); $geckoboard_data = array(); //var_dump( $sales ); exit; foreach ($sales['sales'] as $sale) { $geckoboard_sale = new stdClass(); $geckoboard_sale->title = new stdClass(); $geckoboard_sale->title->text = $sale['email']; $geckoboard_sale->description = date(apply_filters('edd_geckoboard_list_date_format', 'm/d H:m'), strtotime($sale['date'])) . ' / ' . html_entity_decode(edd_currency_symbol(edd_get_option('currency', 'USD'))) . edd_format_amount($sale['total']); array_push($geckoboard_data, $geckoboard_sale); } // Geckoboard handles the list widget in a silly way // As a result, we have to hijack the API output and // handle it ourselves. header('Content-Type: application/json'); echo json_encode($geckoboard_data); exit; break; } if ($geckoboard_data) { $data = $geckoboard_data; } return $data; }
public static function payment_creation_form() { // Determine our float accuracy for the steps and rounding $decimals = edd_currency_decimal_filter(); if (empty($decimals)) { $step = 1; } else { $i = 1; $step = '0.'; while ($i < $decimals) { $step .= '0'; $i++; } $step .= '1'; $step = (double) $step; } $tax_included = 'false'; if (edd_use_taxes() && edd_prices_include_tax()) { $tax_included = 'true'; } $columns = 4; ?> <div class="wrap"> <h2><?php _e('Create New Payment', 'edd-manual-purchases'); ?> </h2> <script type="text/javascript"> jQuery(document).ready(function($) { $(document.body).on('input', '.edd-mp-amount,.edd-mp-tax,.edd-mp-quantity', function() { eddmp_update_total(); }); // check for variable prices $('#edd_mp_create_payment').on('change', '.mp-downloads', function() { var $this = $(this); var selected_download = $('option:selected', this).val(); $this.parent().parent().find('.download-price-option-wrap').html(''); if( parseInt( selected_download ) != 0) { var edd_mp_nonce = $('#edd_create_payment_nonce').val(); var key = $this.parent().parent().data('key'); $.ajax({ type: "POST", url: ajaxurl, data: { action: 'edd_mp_check_for_variations', download_id: selected_download, key: key, nonce: edd_mp_nonce }, dataType: "json", success: function(response) { $this.parent().parent().find('.download-price-option-wrap').html( response.html ); $this.parent().parent().find('input[name="downloads['+ key +'][amount]"]').val( response.amount ); eddmp_update_total(); } }).fail(function (data) { if ( window.console && window.console.log ) { console.log( data ); } }); } else { $this.parent().parent().find('.download-price-option-wrap').html('N/A'); } }); // Update the price when a variation changes $('#edd_mp_create_payment').on('change', '.edd-mp-price-select', function() { var $this = $(this); var price_id = $('option:selected', this).val(); var edd_mp_nonce = $('#edd_create_payment_nonce').val(); var key = $this.parent().parent().data('key'); var download_id = $('select[name="downloads[' + key + '][id]"]').val(); $.ajax({ type: "POST", url: ajaxurl, data: { action: 'edd_mp_variation_change', download_id: download_id, price_id: price_id, key: key, nonce: edd_mp_nonce }, dataType: "json", success: function(response) { $this.parent().parent().find('input[name="downloads['+ key +'][amount]"]').val( response.amount ); eddmp_update_total(); } }).fail(function (data) { if ( window.console && window.console.log ) { console.log( data ); } }); }); $('.edd_add_repeatable').click(function() { setTimeout( function() { $('.edd_repeatable_row:last').find('.download-price-option-wrap').html(''); $('.edd_repeatable_row:last').find('.edd-mp-quantity').val('1'); }, 300 ); }); $(document.body).on('click', '.edd_remove_repeatable', function() { setTimeout( function() { var row_count = $('.edd_repeatable_row').length; if ( 1 === row_count ) { var current_quantity = $('.edd_repeatable_row:first').find('.edd-mp-quantity').val(); if ( '' === current_quantity ) { $('.edd_repeatable_row:first').find('.edd-mp-quantity').val('1'); } } eddmp_update_total(); }, 100 ); }); if ($('.form-table .edd_datepicker').length > 0) { var dateFormat = 'mm/dd/yy'; $('.edd_datepicker').datepicker({ dateFormat: dateFormat }); } function eddmp_update_total() { // Setup some place holder vars for each row var item_amount = 0; var item_tax = 0; var item_quantity = 1; var item_total = 0; // Our final total to show to the customer var total = 0; var prices_include_tax = <?php echo $tax_included; ?> ; // Iterate over each line item and add amount + tax * quantity to get the total $('.edd_repeatable_row').each(function() { var row = $(this); item_amount = parseFloat( row.find('.edd-mp-amount').val() ); if (row.find('.edd-mp-tax').length) { item_tax = parseFloat(row.find('.edd-mp-tax').val() ); if (! isNaN(item_tax) && ! prices_include_tax) { item_amount = item_amount + item_tax; } } if (row.find('.edd-mp-quantity').length) { item_quantity = parseFloat(row.find('.edd-mp-quantity').val() ); } item_total = item_amount * item_quantity; total += item_total; }); if ( isNaN( total ) ){ total = 0; } $('#edd-mp-total-amount').html(total.toFixed(<?php echo $decimals; ?> )); } }); </script> <form id="edd_mp_create_payment" method="post"> <table class="form-table" id="edd-customer-details"> <tbody id="edd-mp-table-body"> <tr class="form-field edd-mp-download-wrap"> <th scope="row" valign="top"> <label><?php echo edd_get_label_plural(); ?> </label> </th> <td class="edd-mp-downloads"> <div id="edd_file_fields" class="edd_meta_table_wrap"> <table class="widefat edd_repeatable_table" style="width: auto;" cellpadding="0" cellspacing="0"> <thead> <tr> <th style="padding: 10px;"><?php echo edd_get_label_plural(); ?> </th> <th style="padding: 10px;"><?php _e('Price Option', 'edd-manual-purchases'); ?> </th> <th style="padding: 10px; width: 150px;"><?php _e('Amount', 'edd-manual-purchases'); ?> </th> <?php if (edd_use_taxes()) { ?> <th style="padding: 10px; width: 150px;"><?php _e('Tax', 'edd-manual-purchases'); ?> </th> <?php $columns++; ?> <?php } if (edd_item_quantities_enabled()) { ?> <th style="padding: 10px; width: 50px;"><?php _e('Quantity', 'edd-manual-purchases'); ?> </th> <?php $columns++; ?> <?php } ?> <th style="padding: 10px; width: 5px;" </tr> </thead> <tbody> <tr class="edd_repeatable_product_wrapper edd_repeatable_row" data-key="1"> <td> <?php echo EDD()->html->product_dropdown(array('name' => 'downloads[1][id]', 'id' => 'downloads', 'class' => 'mp-downloads', 'multiple' => false, 'chosen' => true)); ?> </td> <td class="download-price-option-wrap"><?php _e('N/A', 'edd-manual-purchases'); ?> </td> <td> <input type="number" step="<?php echo $step; ?> " class="edd-mp-amount" name="downloads[1][amount]" value="" min="0" placeholder="<?php esc_attr_e('Item price', 'edd-manual-purchases'); ?> "/> </td> <?php if (edd_use_taxes()) { ?> <td> <?php if (!edd_prices_include_tax()) { ?> + <?php } ?> <input type="number" style="width: 65%" step="<?php echo $step; ?> " class="edd-mp-tax" name="downloads[1][tax]" value="" min="0" placeholder="<?php esc_attr_e('Item Tax', 'edd-manual-purchases'); ?> "/> </td> <?php } ?> <?php if (edd_item_quantities_enabled()) { ?> <td> × <input type="number" step="1" class="edd-mp-quantity" style="width: 65%" name="downloads[1][quantity]" value="1" min="1" placeholder="<?php esc_attr_e('Enter quantity', 'edd-manual-purchases'); ?> "/> </td> <?php } ?> <td> <a href="#" class="edd_remove_repeatable" data-type="file" style="background: url(<?php echo admin_url('/images/xit.gif'); ?> ) no-repeat;">×</a> </td> </tr> <tr> <td class="submit" colspan="<?php echo $columns; ?> " style="float: none; clear:both; background: #fff;"> <a class="button-secondary edd_add_repeatable" style="margin: 6px 0 10px;"><?php _e('Add New', 'edd-manual-purchases'); ?> </a> <span style="line-height: 38px;"> Total: <?php echo edd_currency_symbol(); ?> <span id="edd-mp-total-amount">0.00</span> <?php if (edd_use_taxes()) { ?> <sup>†</sup> <?php } ?> </span> </td> </tr> </tbody> </table> </div> <span> <small> <?php if (edd_use_taxes()) { ?> <sup>†</sup> <?php if (!edd_prices_include_tax()) { ?> <em><?php _e('Total is based on prices exclusive of tax.', 'edd-manual-purchases'); ?> </em> <?php } else { ?> <em><?php _e('Total is based on prices inclusive of tax.', 'edd-manual-purchases'); ?> </em> <?php } ?> <?php } ?> </small> </span> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-user"><?php _e('Customer', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-email"> <div class="customer-info"> <?php echo EDD()->html->customer_dropdown(array('name' => 'customer')); ?> </div> <div class="description customer-info"> <a href="#new" class="edd-payment-new-customer" title="<?php _e('New Customer', 'edd-manual-purchases'); ?> "><?php _e('Create new customer', 'edd-manual-purchases'); ?> </a> </div> <div class="description new-customer" style="display: none"> <a href="#cancel" class="edd-payment-new-customer-cancel" title="<?php _e('Existing Customer', 'edd-manual-purchases'); ?> "><?php _e('Select existing customer', 'edd-manual-purchases'); ?> </a> </div> </td> </tr> <tr class="form-field new-customer" style="display: none"> <th scope="row" valign="top"> <label for="edd-mp-user"><?php _e('Customer Email', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-email"> <input type="text" class="small-text" id="edd-mp-email" name="email" style="width: 180px;"/> <div class="description"><?php _e('Enter the email address of the customer.', 'edd-manual-purchases'); ?> </div> </td> </tr> <tr class="form-field new-customer" style="display: none"> <th scope="row" valign="top"> <label for="edd-mp-last"><?php _e('Customer First Name', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-last"> <input type="text" class="small-text" id="edd-mp-last" name="first" style="width: 180px;"/> <div class="description"><?php _e('Enter the first name of the customer (optional).', 'edd-manual-purchases'); ?> </div> </td> </tr> <tr class="form-field new-customer" style="display: none"> <th scope="row" valign="top"> <label for="edd-mp-last"><?php _e('Customer Last Name', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-last"> <input type="text" class="small-text" id="edd-mp-last" name="last" style="width: 180px;"/> <div class="description"><?php _e('Enter the last name of the customer (optional).', 'edd-manual-purchases'); ?> </div> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-amount"><?php _e('Amount', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-downloads"> <input type="text" class="small-text" id="edd-mp-amount" name="amount" style="width: 180px;"/> <?php if (edd_item_quantities_enabled()) { ?> <div class="description"><?php _e('Enter the total purchase amount, or leave blank to auto calculate price based on the selected items and quantities above. Use 0.00 for 0.', 'edd-manual-purchases'); ?> </div> <?php } else { ?> <div class="description"><?php _e('Enter the total purchase amount, or leave blank to auto calculate price based on the selected items above. Use 0.00 for 0.', 'edd-manual-purchases'); ?> </div> <?php } ?> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <?php _e('Payment status', 'edd-manual-purchases'); ?> </th> <td class="edd-mp-status"> <?php echo EDD()->html->select(array('name' => 'status', 'options' => edd_get_payment_statuses(), 'selected' => 'publish', 'show_option_all' => false, 'show_option_none' => false)); ?> <label for="edd-mp-status" class="description"><?php _e('Select the status of this payment.', 'edd-manual-purchases'); ?> </label> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-payment-method"><?php _e('Payment Method', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-gateways"> <select name="gateway" id="edd-mp-payment-method"> <option value="manual_purchases"><?php esc_html_e('Manual Payment', 'edd-manual-purchases'); ?> </option> <?php foreach (edd_get_payment_gateways() as $gateway_id => $gateway) { ?> <option value="<?php echo esc_attr($gateway_id); ?> "><?php echo esc_html($gateway['admin_label']); ?> </option> <?php } ?> </select> <div class="description"><?php _e('Select the payment method used.', 'edd-manual-purchases'); ?> </div> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-transaction-id"><?php _e('Transaction ID', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-downloads"> <input type="text" class="small-text" id="edd-mp-transaction-id" name="transaction_id" style="width: 180px;"/> <div class="description"><?php _e('Enter the transaction ID, if any.', 'edd-manual-purchases'); ?> </div> </td> </tr> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-date"><?php _e('Date', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-downloads"> <input type="text" class="small-text edd_datepicker" id="edd-mp-date" name="date" style="width: 180px;"/> <div class="description"><?php _e('Enter the purchase date, or leave blank for today\'s date.', 'edd-manual-purchases'); ?> </div> </td> </tr> <?php if (function_exists('eddc_record_commission')) { ?> <tr class="form-field"> <th scope="row" valign="top"> <?php _e('Commission', 'edd-manual-purchases'); ?> </th> <td class="edd-mp-downloads"> <label for="edd-mp-commission"> <input type="checkbox" id="edd-mp-commission" name="commission" style="width: auto;"/> <?php _e('Record commissions (if any) for this manual purchase?', 'edd-manual-purchases'); ?> </label> </td> </tr> <?php } ?> <?php if (class_exists('EDD_Simple_Shipping')) { ?> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-shipped"><?php _e('Shipped', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-shipped"> <label for="edd-mp-shipped"> <input type="checkbox" id="edd-mp-shipped" name="shipped" style="width: auto;"/> <?php _e('Mark order as shipped?', 'edd-manual-purchases'); ?> </label> </td> </tr> <?php } ?> <?php if (class_exists('EDD_Wallet')) { ?> <tr class="form-field"> <th scope="row" valign="top"> <label for="edd-mp-wallet"><?php _e('Pay From Wallet', 'edd-manual-purchases'); ?> </label> </th> <td class="edd-mp-wallet"> <label for="edd-mp-wallet"> <input type="checkbox" id="edd-mp-wallet" name="wallet" style="width: auto;"/> <?php _e('Use funds from the customers\' wallet to pay for this payment.', 'edd-manual-purchases'); ?> </label> </td> </tr> <?php } ?> <tr class="form-field"> <th scope="row" valign="top"> <?php _e('Send Receipt', 'edd-manual-purchases'); ?> </th> <td class="edd-mp-receipt"> <label for="edd-mp-receipt"> <input type="checkbox" id="edd-mp-receipt" name="receipt" style="width: auto;" checked="1" value="1"/> <?php _e('Send the purchase receipt to the buyer?', 'edd-manual-purchases'); ?> </label> </td> </tr> </tbody> </table> <?php wp_nonce_field('edd_create_payment_nonce', 'edd_create_payment_nonce'); ?> <input type="hidden" name="edd-gateway" value="manual_purchases"/> <input type="hidden" name="edd-action" value="create_payment" /> <?php submit_button(__('Create Payment', 'edd-manual-purchases')); ?> </form> </div> <?php }
/** * Slackedd Notification Codes * * @since 1.0.0 */ function slackedd_notification($payment_id) { $edd_options = edd_get_settings(); /* Check that the user has all required information added for the plugin to work */ $enable_slack = isset($edd_options['slackedd_enable_notification']) ? $edd_options['slackedd_enable_notification'] : ''; $hide_order_number = isset($edd_options['slackedd_hide_order_number']) ? $edd_options['slackedd_hide_order_number'] : ''; $hide_order_items = isset($edd_options['slackedd_hide_order_items']) ? $edd_options['slackedd_hide_order_items'] : ''; $hide_payment_gateway = isset($edd_options['slackedd_hide_payment_gateway']) ? $edd_options['slackedd_hide_payment_gateway'] : ''; $hide_buyer_information = isset($edd_options['slackedd_hide_buyer_information']) ? $edd_options['slackedd_hide_buyer_information'] : ''; $slack_channel = isset($edd_options['slackedd_channel']) ? $edd_options['slackedd_channel'] : ''; $webhook_url = isset($edd_options['slackedd_webhook_url']) ? $edd_options['slackedd_webhook_url'] : ''; if (!($enable_slack && $slack_channel && $webhook_url)) { return; } $enable_slack = isset($edd_options['slackedd_enable_notification']) ? $edd_options['slackedd_enable_notification'] : ''; $emoji = !empty($edd_options['slackedd_icon_emoji']) ? $edd_options['slackedd_icon_emoji'] : ':moneybag:'; $bot_name = !empty($edd_options['slackedd_bot_name']) ? $edd_options['slackedd_bot_name'] : 'Slackedd'; $order_amount = esc_attr(edd_format_amount(edd_get_payment_amount($payment_id))); $currency_symbol = edd_currency_symbol($payment_meta['currency']); $currency_symbol = html_entity_decode($currency_symbol, ENT_QUOTES, 'UTF-8'); $payment_meta = edd_get_payment_meta($payment_id); $cart_items = edd_get_payment_meta_cart_details($payment_id); $items_sold = ''; $order_id = edd_get_payment_number($payment_id); foreach ($cart_items as $key => $cart_item) { $name = $cart_item['name']; $price = $cart_item['price']; $items_sold .= "*Name:* " . $name . " | *Price:* " . $currency_symbol . "" . $price . " \n"; } $gateway = edd_get_payment_gateway($payment_id); $payment_method = edd_get_gateway_admin_label($gateway); $user_data = $payment_meta['user_info']; /* Display the new sale introduction */ $message = "A new sale has occurred at " . get_bloginfo('name') . " \n\n"; /* Show or hide order number based on user preference in settings page */ if (!$hide_order_number) { $message .= "*Order* <" . get_bloginfo('home') . "/wp-admin/edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=" . $order_id . "|#" . $order_id . "> \n"; } /* Show the order total */ $message .= "*Order Total:* " . $currency_symbol . "" . $order_amount . " \n\n"; /* Show or hide payment gateway based on user preference in settings page */ if (!$hide_payment_gateway) { $message .= "*Payment Method:* " . $payment_method . " \n\n"; } /* Show or hide order items based on user preference in settings page */ if (!$hide_order_items) { $message .= "*" . edd_get_cart_quantity() . " ITEM(S):* \n"; $message .= $items_sold; } /* Show or hide order number based on user preference in settings page */ if (!$hide_buyer_information) { $message .= "\n\n *Customer:* " . $user_data['first_name'] . " " . $user_data['last_name'] . " " . $user_data['email'] . "\n"; } $attachment = array(); $attachment[] = array('color' => 'good', 'fallback' => 'New sale notification of ' . $currency_symbol . '' . $price . ' at ' . get_bloginfo('name'), 'mrkdwn_in' => array('text'), 'text' => $message, 'title' => 'New Sale Notification!'); $payload = array('attachments' => $attachment, 'channel' => $slack_channel, 'icon_emoji' => $emoji, 'username' => $bot_name); $args = array('body' => json_encode($payload), 'timeout' => 30); $response = wp_remote_post($webhook_url, $args); return; }