/** * Gets package formatted price * * @access public * @param $package_id * @return bool|string */ public static function get_package_formatted_price($package_id) { $price = get_post_meta($package_id, REALIA_PACKAGE_PREFIX . 'price', true); return Realia_Price::format_price($price); }
<form method="post" action="<?php echo get_permalink($payment_page_id); ?> "> <input type="hidden" name="payment_type" value="pay_per_post"> <input type="hidden" name="object_id" value="<?php the_ID(); ?> "> <button type="submit"> <?php echo __('Publish', 'realia'); ?> <span class="label label-primary"><?php echo Realia_Price::format_price($price); ?> </span> <i class="fa fa-arrow-circle-o-right buy"></i> </button> </form> <?php } ?> <?php } elseif ($submission_type == 'packages') { ?> <?php } ?>
/** * Prepares payment data * * @access public * @param $payment_type * @param $object_id * @return array|bool */ public static function get_data($payment_type, $object_id) { $data = array(); $post = get_post($object_id); $currencies = get_theme_mod('realia_currencies', array()); if (!empty($currencies) && is_array($currencies)) { $currency = array_shift($currencies); $currency_code = $currency['code']; $currency_sign = $currency['symbol']; } else { $currency_code = 'USD'; $currency_sign = '$'; } switch ($payment_type) { case 'pay_for_featured': $price = get_theme_mod('realia_submission_featured_price'); $data = array('title' => __('Feature property', 'realia'), 'description' => sprintf(__('Feature property %s', 'realia'), $post->post_title), 'price' => $price, 'price_formatted' => Realia_Price::format_price($price), 'currency_code' => $currency_code, 'currency_sign' => $currency_sign); break; case 'pay_for_sticky': $price = get_theme_mod('realia_submission_sticky_price'); $data = array('title' => __('Sticky property', 'realia'), 'description' => sprintf(__('Sticky property %s', 'realia'), $post->post_title), 'price' => $price, 'price_formatted' => Realia_Price::format_price($price), 'currency_code' => $currency_code, 'currency_sign' => $currency_sign); break; case 'pay_per_post': $price = get_theme_mod('realia_submission_pay_per_post_price'); $data = array('title' => __('Publish property', 'realia'), 'description' => sprintf(__('Publish property %s', 'realia'), $post->post_title), 'price' => $price, 'price_formatted' => Realia_Price::format_price($price), 'currency_code' => $currency_code, 'currency_sign' => $currency_sign); break; case 'package': $price = get_post_meta($object_id, REALIA_PACKAGE_PREFIX . 'price', true); $data = array('title' => __('Purchase package', 'realia'), 'description' => sprintf(__('Upgrade package to %s', 'realia'), $post->post_title), 'price' => $price, 'price_formatted' => Realia_Price::format_price($price), 'currency_code' => $currency_code, 'currency_sign' => $currency_sign); break; default: return false; } return $data; }
<?php } elseif ($payment_type == 'package') { ?> <?php if (!empty($object_id)) { ?> <?php $title = get_the_title($object_id); ?> <?php $price = get_post_meta($object_id, REALIA_PACKAGE_PREFIX . 'price', true); ?> <div class="payment-info"> <?php echo sprintf(__('You are going to pay <strong>%s</strong> for package <strong>"%s"</strong>.', 'realia'), Realia_Price::format_price($price), $title); ?> </div><!-- /.payment-info --> <?php } else { ?> <div class="payment-info"> <?php echo __('Missing package.', 'realia'); ?> </div><!-- /.payment-info --> <?php } ?> <?php } else {