Jump to content

How to do this?


Recommended Posts

I have a salespage that has some parts of the design that need translating depending on the language.

In the following code I have placed __('ADD TO CART') but something goes wrong, the front end now shows this in the button text

I have one more instance of a translate in the code __('Most popular'), also not working, here's the code:

<?php

	function getProductOptions($page) {
		$availableProductOptions = wire('page')->available_product_options;
		$options = "<ul>";

		foreach ($availableProductOptions as $option) {
			if ($page->get($option)) {
				$options .= "<li class='check'><span>" . $option->title . "</span></li>";
			}
			else {
				$options .= "<li class='lack'><span>" . $option->title . "</span></li>";
			}
		}
		$options .= "</ul>";
		return $options;
	}

	function getProductPlans() {
		$out = "";
		$bestValue = null;

		foreach (wire('page')->product_plans_repeater->find('limit=3') as $plan) {
			$planOptions = "";
			$price = explode('.', $plan->t_field_2);
			$price = "$price[0]<sup>.$price[1]</sup>";
			$arrow = "";
			$label = "<h2 class='most-popular-label empty'> </h2>";
			if ($plan->checkbox_field && !$bestValue) {
				$bestValue = $plan->plan_color->title;
				$arrow = "<div class='arrow " . $bestValue . "'>
							<div class='best-value '>
								<div class='inner'>
									" . wire('page')->t_area_5 . "
								</div>
							</div>
						</div>";

				$label = "<h2 class='most-popular-label'><span>__('Most popular')</span></h2>";
			}

			$out .= "
				<div class='plan " . $plan->plan_color->title . "'>
					" . $label . "
					<div class='inner'>
						<header>
							<p>" . $plan->t_field . "</p>
							<span itemprop='name'>" . $plan->t_field_1 . "</span>
						</header>
						<div itemprop='price' class='price'>" . $price . "</div>
						<div class='options'>" . getProductOptions($plan->custom_pages_field) . "</div>
						<div class='action'><a class='add-to-cart-button' href='" . $plan->page_field . "'><span>__('ADD TO CART')</span></a></div>
					</div>
					" . $arrow . "
				</div>
			";
		}

		if ($bestValue) {
			$out .= "
				<div class='best-value " . $bestValue . "'>
					<div class='inner'>
						" . wire('page')->t_area_5 . "
					</div>
				</div>
			";
		}

		echo $out;
	}

?>

thanks!

Link to comment
Share on other sites

Found it already, posting for others and my own leaky memory...

<div class='action'><a class='add-to-cart-button' href='" . $plan->page_field . "'><span>".__('ADD TO CART')."</span></a></div>

needed to close stuff off with " and then start and end with dots, .__('ADD TO CART').

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...