/** * Get refund request args * @param WC_Order $order * @param float $amount * @param string $reason * @return array */ public static function get_request($order, $amount = null, $reason = '') { $request = array('VERSION' => '84.0', 'SIGNATURE' => self::$api_signature, 'USER' => self::$api_username, 'PWD' => self::$api_password, 'METHOD' => 'RefundTransaction', 'TRANSACTIONID' => $order->get_transaction_id(), 'NOTE' => html_entity_decode(wc_trim_string($reason, 255), ENT_NOQUOTES, 'UTF-8'), 'REFUNDTYPE' => 'Full'); if (!is_null($amount)) { $request['AMT'] = number_format($amount, 2, '.', ''); $request['CURRENCYCODE'] = $order->get_order_currency(); $request['REFUNDTYPE'] = 'Partial'; } return apply_filters('woocommerce_paypal_refund_request', $request, $order, $amount, $reason); }
/** * Add PayPal Line Item * @param string $item_name * @param integer $quantity * @param integer $amount * @param string $item_number * @return bool successfully added or not */ protected function add_line_item($item_name, $quantity = 1, $amount = 0, $item_number = '') { $index = sizeof($this->line_items) / 4 + 1; if ($amount < 0 || $index > 9) { return false; } $this->line_items['item_name_' . $index] = html_entity_decode(wc_trim_string($item_name ? $item_name : __('Item', 'woocommerce'), 127), ENT_NOQUOTES, 'UTF-8'); $this->line_items['quantity_' . $index] = $quantity; $this->line_items['amount_' . $index] = $amount; $this->line_items['item_number_' . $index] = $item_number; return true; }
/** * Test wc_trim_string(). * * @since 2.2 */ public function test_wc_trim_string() { $this->assertEquals('string', wc_trim_string('string')); $this->assertEquals('s...', wc_trim_string('string', 4)); $this->assertEquals('st.', wc_trim_string('string', 3, '.')); $this->assertEquals('string¥', wc_trim_string('string¥', 7, '')); }
/** * Add PayPal Line Item. * @param string $item_name * @param int $quantity * @param float $amount * @param string $item_number * @return bool successfully added or not */ protected function add_line_item($item_name, $quantity = 1, $amount = 0, $item_number = '') { $index = sizeof($this->line_items) / 4 + 1; if ($amount < 0 || $index > 9) { return false; } $item = apply_filters('woocommerce_paypal_line_item', array('item_name' => html_entity_decode(wc_trim_string($item_name ? $item_name : __('Item', 'woocommerce'), 127), ENT_NOQUOTES, 'UTF-8'), 'quantity' => (int) $quantity, 'amount' => (double) $amount, 'item_number' => $item_number), $item_name, $quantity, $amount, $item_number); $this->line_items['item_name_' . $index] = $item['item_name']; $this->line_items['quantity_' . $index] = $item['quantity']; $this->line_items['amount_' . $index] = $item['amount']; $this->line_items['item_number_' . $index] = $item['item_number']; return true; }
/** * Print the columns information * * @param $review * @param $column_name * * @return string */ public function column_default($review, $column_name) { switch ($column_name) { case $this->ywar->custom_column_review: $post = get_post($review->ID); if (empty($post->post_title) && empty($post->post_content)) { return; } $edit_link = get_edit_post_link($review->ID); echo '<a class="row-title" href="' . $edit_link . '">'; if (!empty($post->post_title)) { echo '<span class="review-title">' . wc_trim_string($post->post_title, 80) . '</span>'; echo "<br>"; } if (!empty($post->post_content)) { echo '<span class="review-content">' . wc_trim_string($post->post_content, 80) . '</span>'; } echo '</a>'; $post_type_object = get_post_type_object($this->ywar->post_type_name); if ('trash' == $post->post_status) { $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the bin') . "' href='" . $this->ywar->untrash_review_url($post) . "'>" . __('Restore') . "</a>"; } elseif (EMPTY_TRASH_DAYS) { $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the bin') . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Bin') . "</a>"; } if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) { $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently') . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete permanently') . "</a>"; } $actions = apply_filters('yith_advanced_reviews_row_actions', $actions, $post); echo $this->row_actions($actions); break; case $this->ywar->custom_column_rating: if (0 == $review->post_parent) { $rating = get_post_meta($review->ID, $this->ywar->meta_key_rating, true); echo '<div class="woocommerce"> <div class="star-rating" title="' . sprintf(__("Rated %d out of 5", 'yith-woocommerce-advanced-reviews'), $rating) . '"> <span style="width:' . $rating / 5 * 100 . '%"><strong>' . $rating . '</strong>' . __("out of 5", 'yith-woocommerce-advanced-reviews') . ' </span> </div> </div>'; } break; case $this->ywar->custom_column_product: $product_id = get_post_meta($review->ID, $this->ywar->meta_key_product_id, true); echo get_the_title($product_id) . "<br>"; if (current_user_can('edit_post', $product_id)) { echo "<a class='edit-product-review' href='" . get_edit_post_link($product_id) . "'>" . __("Edit", 'yith-woocommerce-advanced-reviews') . '</a>'; } echo "<a class='view-product-review' href='" . get_permalink($product_id) . "' target='_blank'>" . __("View", 'yith-woocommerce-advanced-reviews') . '</a>'; break; case $this->ywar->custom_column_author: if ($review->post_author) { $user = get_userdata($review->post_author); $author_name = $user ? $user->display_name : __('Anonymous', 'yith-woocommerce-advanced-reviews'); } else { $user = yit_get_post_meta($review->ID, $this->ywar->meta_key_review_author); if ($user) { $author_name = $user ? $user : __('Anonymous', 'yith-woocommerce-advanced-reviews'); } } echo $author_name; break; case $this->ywar->custom_column_date: $t_time = get_the_time(__('Y/m/d g:i:s a')); $m_time = $review->post_date; $time = get_post_time('G', true, $review); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; break; default: do_action('yith_advanced_reviews_show_advanced_reviews_columns', $column_name, $review->ID); } return null; }
public function add_line_item_own($item_name, $quantity = 1, $amount = 0, $item_number = '', $productid = 0) { $index = sizeof($this->line_items) / 5 + 1; if (!$item_name || $amount < 0) { return false; } $this->line_items['item_name_' . $index] = html_entity_decode(wc_trim_string($item_name, 127), ENT_NOQUOTES, 'UTF-8'); $this->line_items['quantity_' . $index] = $quantity; $this->line_items['amount_' . $index] = $amount; $this->line_items['item_number_' . $index] = $item_number; $this->line_items['product_number_' . $index] = $productid; $_SESSION['line_item'] = $this->line_items; return true; }